[Zope] InvokeFactory Question
David Pratt
fairwinds at eastlink.ca
Mon Jan 31 20:58:12 EST 2005
Hi. I have written a small Script Python to create a Portal Folder in a
specific Folder (root/information) using a form. This creates the
Portal Folder I want but instead of creating it in the information
folder, I find it in the root folder. Can someone point out what I am
doing wrong. If I use getId() on info_dir it gives me 'information'
as the id so it appears I am creating it with the right object. I have
manager proxy on the Script Python as well.
Regards,
David
# Get portal url object
url_tool = getToolByName(context, 'portal_url')
# Get the path from the object
portal_path = url_tool.getPortalPath()
# Information directory (Folder) object
info_dir = context.restrictedTraverse('%s/information' % portal_path)
# Cancel button action
if form_cancel is not None:
RESPONSE.redirect('index_html?start:int=%s&sort=%s&reverse:int=%s'
%(start, sort, reverse))
return None
# Save button action
if form_save is not None:
category_id = context.cleanId(category_id)
# Create a Portal Folder object
info_dir.invokeFactory('Folder', category_id)
# Get a handle on the new object created
folder_obj = getattr(info_dir, category_id)
# Get and fill the fields
folder_obj.setTitle(title)
folder_obj.setDescription(description)
RESPONSE.redirect('index_html?start:int=%s&sort=%s&reverse:int=%s'
%(start, sort, reverse))
return None
More information about the Zope
mailing list