[CMF-checkins] CVS: CMF/CMFWorkspaces - OrganizationTool.py:1.3
Shane Hathaway
shane@cvs.zope.org
Thu, 6 Jun 2002 11:13:23 -0400
Update of /cvs-repository/CMF/CMFWorkspaces
In directory cvs.zope.org:/tmp/cvs-serv27755
Modified Files:
OrganizationTool.py
Log Message:
- Keep track of the location of the workspace, so that the factory can add
the item to the workspace in addition to the container.
- Made the icon in workspaces clickable.
=== CMF/CMFWorkspaces/OrganizationTool.py 1.2 => 1.3 ===
import os
+from urllib import quote
from Acquisition import aq_inner, aq_parent
from Globals import InitializeClass, DTMLFile
@@ -70,16 +71,31 @@
security.declarePublic('getAddFormURL')
- def getAddFormURL(self, type_name):
+ def getAddFormURL(self, type_name, workspace=None):
"""Returns the URL to visit to add an object of the given type.
"""
- base = aq_parent(aq_inner(self)).absolute_url()
location, skin_name = self._types[str(type_name)]
if not location.startswith('/'):
location = '/' + location
- if not location.endswith('/'):
- location = location + '/'
- return base + location + skin_name
+ base = aq_parent(aq_inner(self)).absolute_url()
+ base_url = base + location
+ if not base_url.endswith('/'):
+ base_url = base_url + '/'
+ ws = ''
+ if workspace is not None:
+ ws = '&workspace=%s' % quote(
+ '/'.join(workspace.getPhysicalPath()))
+ return '%s%s?type=%s%s' % (base_url, skin_name, quote(type_name), ws)
+
+
+ security.declarePublic('getTypeContainer')
+ def getTypeContainer(self, type_name):
+ """Returns the container for a given type."""
+ portal = aq_parent(aq_inner(self))
+ location, skin_name = self._types[str(type_name)]
+ if location.startswith('/'):
+ location = location[1:]
+ return portal.restrictedTraverse(location)
security.declareProtected(ManagePortal, 'getLocationInfo')