[CMF-checkins] CVS: CMF/CMFWorkspaces - tool.gif:1.1 OrganizationTool.py:1.2 __init__.py:1.2
Shane Hathaway
shane@cvs.zope.org
Fri, 24 May 2002 13:49:08 -0400
Update of /cvs-repository/CMF/CMFWorkspaces
In directory cvs.zope.org:/tmp/cvs-serv27973
Modified Files:
OrganizationTool.py __init__.py
Added Files:
tool.gif
Log Message:
Linked in the organization tool.
=== Added File CMF/CMFWorkspaces/tool.gif ===
<Binary-ish file>
=== CMF/CMFWorkspaces/OrganizationTool.py 1.1.1.1 => 1.2 ===
import os
+from Acquisition import aq_inner, aq_parent
from Globals import InitializeClass, DTMLFile
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from OFS.SimpleItem import SimpleItem
@@ -47,6 +48,8 @@
, { 'label': 'Placement', 'action': 'manage_placement' },
) + SimpleItem.manage_options
+ _types = {} # type name -> (location, skin name)
+
#
# ZMI methods
#
@@ -60,22 +63,53 @@
# 'OrganizationTool' interface methods
#
- security.declarePublic('listAddableTypes' )
+ security.declarePublic('listAddableTypes')
def listAddableTypes(self):
- """Returns the list of types that can be added without specifying
- a location beforehand."""
- return ('Document', 'File')
+ """Returns a list of types."""
+ return self._types.keys()
+
+
+ security.declarePublic('getAddFormURL')
+ def getAddFormURL(self, type_name):
+ """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
- security.declarePublic('getAddFormURLs' )
- def getAddFormURLs(self):
- """Returns an object that maps type name to add form URL.
+ security.declareProtected(ManagePortal, 'getLocationInfo')
+ def getLocationInfo(self):
+ """Returns the list of types, locations, and skin names.
"""
base = aq_parent(aq_inner(self)).absolute_url()
- return {
- 'Document': base + '/Documents/document_add_form',
- 'File': base + '/Files/file_add_form',
- }
+ res = []
+ items = self._types.items()
+ items.sort()
+ for key, (location, skin_name) in items:
+ res.append({'type': key,
+ 'location': location,
+ 'skin_name': skin_name,})
+ return res
+
+
+ security.declareProtected(ManagePortal, 'setLocationInfo')
+ def setLocationInfo(self, info, RESPONSE=None):
+ """Sets the list of types, locations, and skin names.
+ """
+ types = {}
+ for r in info:
+ t = str(r.type)
+ if t:
+ types[t] = (str(r.location), str(r.skin_name))
+ self._types = types
+ if RESPONSE is not None:
+ RESPONSE.redirect(self.absolute_url() + '/manage_placement?' +
+ 'manage_tabs_message=Saved+changes.')
InitializeClass(OrganizationTool)
=== CMF/CMFWorkspaces/__init__.py 1.1.1.1 => 1.2 ===
__version__='$Revision$'[11:-2]
+import sys
+
from Products.CMFCore import utils
from Products.CMFCore.DirectoryView import registerDirectory
-import Workspace
+import Workspace, OrganizationTool
registerDirectory('skins', globals())
+tools = (
+ OrganizationTool.OrganizationTool,
+ )
+
+
+this_module = sys.modules[ __name__ ]
+z_tool_bases = utils.initializeBasesPhase1(tools, this_module)
+
def initialize(context):
+ utils.initializeBasesPhase2(z_tool_bases, context)
context.registerBaseClass(Workspace.Workspace)
ADD_FOLDERS_PERMISSION = 'Add portal folders'
@@ -36,6 +47,9 @@
permission=ADD_FOLDERS_PERMISSION,
extra_constructors=(Workspace.addWorkspace,),
fti=Workspace.factory_type_information
- ).initialize( context )
+ ).initialize(context)
+ utils.ToolInit('CMFWorkspaces Tool', tools=tools,
+ product_name='CMFWorkspaces', icon='tool.gif',
+ ).initialize(context)