Commit 4779baed authored by Amos Latteier's avatar Amos Latteier

Made ZClasses easier to call from DTML, and documented the calling interface

a bit.
parent f10f5ddf
...@@ -243,27 +243,31 @@ class ZClass(OFS.SimpleItem.SimpleItem): ...@@ -243,27 +243,31 @@ class ZClass(OFS.SimpleItem.SimpleItem):
manage_options=ComputedAttribute(manage_options) manage_options=ComputedAttribute(manage_options)
def index_html(self, id, REQUEST): def index_html(self, id, REQUEST, RESPONSE=None):
"""Create Z instance """
Create Z instance. If called with a RESPONSE,
the RESPONSE will be redirected to the management
screen of the new instance's parent Folder. Otherwise,
the instance will be returned.
""" """
i=mapply(self._zclass_, (), REQUEST) i=mapply(self._zclass_, (), REQUEST)
if not hasattr(i, 'id') or not i.id: i.id=id if not hasattr(i, 'id') or not i.id: i.id=id
folder=durl=None folder=durl=None
if hasattr(self, 'Destination'): if hasattr(self, 'Destination'):
try: d=self.Destination
d=self.Destination if d.im_self.__class__ is FactoryDispatcher:
if d.im_self.__class__ is FactoryDispatcher: folder=d()
folder=d()
durl=self.DestinationURL()
except: pass
if folder is None: folder=self.aq_parent if folder is None: folder=self.aq_parent
if not hasattr(folder,'_setObject'):
folder=folder.aq_parent
folder._setObject(id, i) folder._setObject(id, i)
if REQUEST.has_key('RESPONSE'): if RESPONSE is not None:
if durl is None: durl=REQUEST['URL3'] try: durl=self.DestinationURL()
REQUEST['RESPONSE'].redirect(durl+'/manage_workspace') except: durl=REQUEST['URL3']
RESPONSE.redirect(durl+'/manage_workspace')
else: else:
return getattr(folder, id) return getattr(folder, id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment