[Zope] Newbie product question

Marie Robichon robichon@esrf.fr
Tue, 20 Aug 2002 17:26:14 +0200


Hi,

In true newbie style I have followed many examples of product making, but 
have got stuck going further....

I would like to subclass OrderedFolder, then as my product is created add a 
page template inside it.
My code (patchwork of other examples) manages to create the 
OrderedFolderish item but no page template is created inside it.  Please be 
indulgent I am not a programmer.....

My code is below,

TIA

Marie


from Products.OrderedFolder import OrderedFolder
from mxm import mxmObjectManager
from Products.PageTemplates.PageTemplate import PageTemplate

class ESRFFolder(OrderedFolder.OrderedFolder, 
mxmObjectManager.mxmObjectManager):

     meta_type = 'ESRF Folder'

     _allowed_meta_types = ('ESRF Folder','Page Template','Image','File')

     _properties = (
         {'id':'title', 'type':'string', 'mode':'w'},
         {'id':'Summary', 'type':'text', 'mode':'w'},
     )

def manage_addAction(self, id=None, REQUEST=None):
     "Add instance to parent ObjectManager"
     mxmObjectManager.addClass(self, id, ESRFFolder, REQUEST)

constructors =  (mxmObjectManager.manage_addForm, manage_addAction)

def manage_afterAdd(self, item, container):
         Folder.manage_afterAdd(self, item, container)

         try: user=REQUEST['AUTHENTICATED_USER']
         except: user=None

         if (user is not None) and not (
             user.has_permission('Add Page Templates', self)):
             raise 'Unauthorized', (
                   'You are not authorized to add Page Templates.'
                    )
         try:
             self._setObject('contents_html', 
PageTemplate.PageTemplate('contents_html'))
         except:
             pass