[Zope] Idea for a new "basic" class
   
    Max Møller Rasmussen
     
    maxm@normik.dk
       
    Tue, 10 Jul 2001 17:01:26 +0200
    
    
  
During my process of discovering Zope, I have made quite a few products. I
have allways found that there is a lot of repeated functionality and code
just to get them up and running.
I have an idea for a "basic" class to be added to the Zope framework that
sets up the most comonly used mixin classes, and sets up sensible default
values for them.
So to make a very simple Zope product you just need to write::
    from basic import basic
    class minimal(basic):
        meta_type = 'minimal'
And it would set up a fully functional product with id, and title as default
vales. manageAdd, manageAction, manage_editForm, manage_editAction, and
index_html would also be included by default.
If you want to add more properties you would just overwrite "_properties"
    from basic import basic
    
    class minimal(basic):
        
        meta_type = 'minimal'
        
        _properties=(
            {'id':'title', 'type':'string', 'mode':'w'},
            {'id':'summary', 'type':'text', 'mode':'w'},
            {'id':'content', 'type':'text', 'mode':'w'},
            {'id':'author', 'type':'string', 'mode':'w'},
            {'id':'url', 'type':'string', 'mode':'w'},
            {'id':'email', 'type':'string', 'mode':'w'},
        )
And the manageAdd, manageAction, manage_editForm, manage_editAction, and
index_html would change dynamically to fit the new properties.
You could also add new methods, or overwrite the default ones like::
    from basic import basic
    from global import DTMLFile
    
    class minimal(basic):
        
        meta_type = 'minimal'
        
        _properties=(
            {'id':'title', 'type':'string', 'mode':'w'},
            {'id':'summary', 'type':'text', 'mode':'w'},
            {'id':'content', 'type':'text', 'mode':'w'},
            {'id':'author', 'type':'string', 'mode':'w'},
            {'id':'url', 'type':'string', 'mode':'w'},
            {'id':'email', 'type':'string', 'mode':'w'},
        )
        
        index_html = DTMLFile('www/index_html', globals())
        
        view = DTMLFile('www/view', globals())
        
        edit = DTMLFile('www/edit', globals())
I believe that it would _greatly_ simplify the process of writing Python
products. Taking the minimal needed code to get started from something like
40 lines to 3.
Does it sound like a waste of time to write this class?? I think it would be
fairly easy, but would anybody use it? And is it possible to get something
like this into the core? If so I am willing to write it.
regards Max M