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
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@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 )
Thanks Robert. I am working in CMF. Sometimes you need someone to point out the obvious. I guess I grabbed the wrong folder type when I made the information folder in the first place in the ZMI. I did not get any feedback from the ZMI that there was anything wrong. I always start with view templates first. I put a number of Portal Folder items into the information folder (a plain Folder type as it turned out) in the first place so I would have some items to create my view template before going on to others. I makes me wonder how a Portal Folder can be made inside a plain Folder in the ZMI and not throw an exception, yet to do it programatically facilitates an unpredictable behavior. Perhaps a TypeError exception should have been raised in both circumstances when there was an attempt to place a Portal Folder type inside a plain Folder. Are there circumstances that you can think of where you would want Portal Folders to be allowed inside plain Folders in CMF. Is this a bug? Regards David On Tuesday, February 1, 2005, at 04:42 AM, robert wrote:
Is your info-folder a CMF/Plone folder? If not it does not have a invokeFactory method. This method would be acquired insted. Robert
I makes me wonder how a Portal Folder can be made inside a plain Folder in the ZMI and not throw an exception, yet to do it programatically facilitates an unpredictable behavior. Perhaps a TypeError exception should have been raised in both circumstances when there was an attempt to place a Portal Folder type inside a plain Folder. Are there circumstances that you can think of where you would want Portal Folders to be allowed inside plain Folders in CMF. Is this a bug? this is the wonder of acquisition Robert
participants (2)
-
David Pratt -
robert