[Zope] Product development

Stefan Heimann stefan.heimann@web.de
Thu, 19 Jul 2001 23:51:17 +0200


Hi!

I have some problems creating my first product. I've read the
Developers Guide and the boring product, but I could not solve 2
problems:

1.) I can select my product from the add list, but
whenever I try to add it to the folder (after submitting the add form)
I get an error message: KeyError: manage_page_header
When I access manage_main via the 'edit' tab of an already created
product, this error does not appear.

2.) I want to add some properties to my product. So I defined the
_properties variable, but my property 'color' does not appear on the
property manage interface.

Here is my source code:


from Acquisition import Implicit
from Globals import Persistent
from AccessControl.Role import RoleManager
from OFS.SimpleItem import Item
from Globals import DTMLFile
from OFS import PropertyManager
from AccessControl import ClassSecurityInfo
from Globals import MessageDialog 


def addMethod(self, id, REQUEST=None):
     """
     Create a new article
     """
     a = Article(id) 
     self._setObject(id, a)
     if REQUEST is not None:
          return a.edit(REQUEST)

addForm = DTMLFile('dtml/addForm', globals())
     
class Article(Implicit, Persistent, RoleManager, PropertyManager, Item):
     """
     Article product class
     """

     meta_type = 'article'
     title = 'Sample article'
     security=ClassSecurityInfo()
     
     manage_options=(
         {'label' : 'Edit', 'action' : 'manage_main'},
         {'label':'Properties', 'action':'manage_propertiesForm',}
         ) + RoleManager.manage_options + Item.manage_options

     _properties=({'id':'color', 'type': 'selection', 'mode': 'w', 'select_variable': 'getColors'},
                  )

     manage_main=DTMLFile('dtml/edit', globals())
     
     def __init__(self,id):
         self.id = id
         self.color = 'green'

     security.declareProtected('Edit article', 'edit')        
     def edit(self, REQUEST=None):
         """
         Updates the content of an article.
         """
         if REQUEST is not None:
             return manage_main(REQUEST, manage_tabs_message='Saved.')

                      
     def getColors(self):
         return ['blue','green','red']


from Globals import InitializeClass
InitializeClass(Article)


Sorry for posting so much code, but I think it's better than forgeting
something important.

Thank you!

Bye Stefan

-- 
Stefan Heimann       | fon: +49 (0761) 3196897
Brandensteinstr. 5   | fax: +49 (01212) 510339818
D-79110 Freiburg     | e-mail: stefan.heimann@web.de