[Zope-Checkins] CVS: Zope/lib/python/App - Management.py:1.48.20.2 ZopeComponents.py:1.1.2.5 __init__.py:1.3.202.3
Shane Hathaway
shane@digicool.com
Fri, 12 Oct 2001 17:52:47 -0400
Update of /cvs-repository/Zope/lib/python/App
In directory cvs.zope.org:/tmp/cvs-serv30945
Modified Files:
Tag: ComponentArchitecture-branch
Management.py ZopeComponents.py __init__.py
Log Message:
- Changed references to "manage_workspace" to "(p)workspace".
- Added a default workspace presentation component.
- Added SimpleAdderEntry and the function provideClass() to make
it easy to register new Zope types.
=== Zope/lib/python/App/Management.py 1.48.20.1 => 1.48.20.2 ===
steps = REQUEST._steps[:-1]
script = REQUEST['BASEPATH1']
- linkpat = '<a href="%s/manage_workspace">%s</a>'
+ linkpat = '<a href="%s/(p)workspace">%s</a>'
out = []
url = linkpat % (script, ' /')
if not steps:
@@ -189,7 +189,7 @@
del path[-1]
for p in path:
script="%s/%s" % (script, quote(p))
- out.append('<a href="%s/manage_workspace">%s</a>' % (script, p))
+ out.append('<a href="%s/(p)workspace">%s</a>' % (script, p))
out.append(last)
return join(out, '/')
@@ -209,7 +209,7 @@
path = self.__class__._v_manage_path_roles = (
'%(product)s/%(id)s' % zclass)
if path:
- return '/Control_Panel/Products/%s/manage_workspace' % path
+ return '/Control_Panel/Products/%s/(p)workspace' % path
Globals.default__class_init__(Tabs)
@@ -275,3 +275,48 @@
setattr(Navigation, 'manage_page_style.css__roles__', None)
Globals.default__class_init__(Navigation)
+
+
+import Acquisition
+import ComponentArchitecture
+from ZPublisher.Browser import BrowserPublish
+
+
+class WorkspacePresentation (Acquisition.Explicit):
+ """
+ """
+
+ __implements__ = BrowserPublish
+
+ def _browser_default(self, request):
+ content = self.aq_parent
+ if hasattr(content, "filtered_manage_options"): # XXX
+ return self, ('view',)
+ else:
+ # Go to the default view.
+ p = ComponentArchitecture.getPresentation(
+ content, '', BrowserPublish)
+ return p._browser_default(request)
+
+ view__roles__=('Authenticated',)
+ def view(self, REQUEST):
+ """
+ """
+ content = self.aq_parent
+ options = content.filtered_manage_options(REQUEST)
+ try:
+ m=options[0]['action']
+ if m=='manage_workspace' or m == '(p)workspace': raise TypeError
+ except:
+ raise 'Unauthorized', (
+ 'You are not authorized to view this object.<p>')
+
+ if find(m,'/'):
+ raise 'Redirect', (
+ "%s/%s" % (REQUEST['URL2'], m))
+
+ return getattr(content, m)(content, REQUEST)
+
+
+ComponentArchitecture.providePresentation(
+ None, 'workspace', BrowserPublish, WorkspacePresentation().__of__)
=== Zope/lib/python/App/ZopeComponents.py 1.1.2.4 => 1.1.2.5 ===
+class SimpleAdderEntry:
+
+ __allow_access_to_unprotected_subobjects__ = 1
+
+ __implements__ = AdderEntry
+
+ def __init__(self, klass, name=None, product=None, description='',
+ interfaces=None, global_visibility=1, permission=None):
+ self.klass = klass
+ self._id = '%s.%s' % (klass.__module__, klass.__name__)
+ self.name = name or klass.__name__
+ if product is None:
+ # Try to discover the product name.
+ names = klass.__module__.split('.')
+ for idx in range(len(names) - 1):
+ if names[idx] == 'Products':
+ product = names[idx + 1]
+ break
+ if product is None:
+ # ??
+ product = klass.__module__
+ self.product = product
+ self.description = description
+ self.interfaces = interfaces
+ self.global_visibility = global_visibility
+ self.permission = permission
+
+ def getId(self):
+ return self._id
+
+ def getName(self):
+ return self.name
+
+ def getProduct(self):
+ return self.product
+
+ def getDescription(self):
+ return self.description
+
+ def isGloballyVisible(self):
+ return self.global_visibility
+
+ def getInterfaces(self):
+ return self.interfaces
+
+ def getPermission(self):
+ return self.permission
+
+ def _invoke(self, adder, id, request):
+ if not id:
+ raise 'An id is required.'
+ ob = self.klass()
+ adder.addToContainer(ob)
+ return adder.resultAfterAdd()
+
+
+
class ClassicAdderEntry:
__allow_access_to_unprotected_subobjects__ = 1
@@ -222,6 +279,18 @@
if _add_registry.has_key(name):
raise 'Already registered', name
_add_registry[name] = FeatureAdderEntry(name, *args, **kw)
+
+
+def provideClass(klass, *args, **kw):
+ """
+ Adds a class to the list of addable types.
+ See SimpleAdderEntry.__init__ for parameter syntax.
+ """
+ entry = SimpleAdderEntry(klass, *args, **kw)
+ name = entry.getName()
+ if _add_registry.has_key(name):
+ raise 'Already registered', name
+ _add_registry[name] = entry
def listAddableTypes(object):
=== Zope/lib/python/App/__init__.py 1.3.202.2 => 1.3.202.3 ===
##############################################################################
-from ZopeComponents import Adder, provideAddPresentation, provideAddFeature
+from ZopeComponents import Adder, provideClass, provideAddPresentation, \
+ provideAddFeature