[Zope] Newbie product question
Andy McKay
andy@agmweb.ca
Tue, 20 Aug 2002 09:23:54 -0700
Take out the except: pass at the bottom of the code. If the PageTemplate is
not being created due to an error, it will tell you the error. Generally
doing an except: pass is considered bad practice as it can hide any problem
and make code hard to debug.
--
Andy McKay
Agmweb Consulting
http://www.agmweb.ca
----- Original Message -----
From: "Marie Robichon" <robichon@esrf.fr>
To: <zope@zope.org>
Sent: Tuesday, August 20, 2002 8:26 AM
Subject: [Zope] Newbie product question
> 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
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>