[Zope] Newbie product question
Max M
maxm@mxm.dk
Wed, 21 Aug 2002 08:38:54 +0200
Marie Robichon wrote:
> 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.....
As it is now your "manage_afterAdd" is an unbound function in the
module. It really should be a class method for it to be called by Zope:
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_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
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)
regards Max M
"klaatu verata niktu"