[Zope] InvokeFactory Question

robert robert at redcor.ch
Tue Feb 1 03:42:47 EST 2005


Is your info-folder a CMF/Plone folder?
If not it does not have a invokeFactory method.
This method would be acquired insted.
Robert

David Pratt wrote:

> 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   
>
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>



More information about the Zope mailing list