From 0de032132c60f51d34beb285e55e27c9f5a68012 Mon Sep 17 00:00:00 2001 From: helmutm Date: Sun, 25 Mar 2007 12:36:21 +0000 Subject: [PATCH] provide 'options' field for loops root and menu objects; make versioning depend on 'useVersioning' option git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1664 fd906abe-77d9-0310-91a1-e0d9ade77398 --- base.py | 4 ++++ browser/common.py | 11 +++++++++++ browser/concept_macros.pt | 19 +++++++++++-------- browser/node.py | 11 +++++++++++ configure.zcml | 2 +- interfaces.py | 14 ++++++++++++++ search/search.pt | 19 +++++++++++-------- 7 files changed, 63 insertions(+), 17 deletions(-) diff --git a/base.py b/base.py index 6256733..4e6aef2 100644 --- a/base.py +++ b/base.py @@ -51,6 +51,10 @@ class Loops(Folder): def setSkinName(self, skinName): self._skinName = skinName skinName = property(getSkinName, setSkinName) + def getOptions(self): return getattr(self, '_options', []) + def setOptions(self, value): self._options = value + options = property(getOptions, setOptions) + def getLoopsRoot(self): return self diff --git a/browser/common.py b/browser/common.py index 7bca5f7..43a0637 100644 --- a/browser/common.py +++ b/browser/common.py @@ -97,6 +97,7 @@ class BaseView(GenericView): self.setSkin(self.loopsRoot.skinName) try: if not canAccess(context, 'title'): + #raise Unauthorized request.response.redirect('login.html') except ForbiddenAttribute: # ignore when testing pass @@ -246,6 +247,14 @@ class BaseView(GenericView): # versioning + @Lazy + def useVersioning(self): + if 'useVersioning' in self.loopsRoot.options: + return True + options = getattr(self.controller, 'options', None) + if options: + return 'useVersioning' in options.value + @Lazy def versionId(self): context = self.context @@ -260,6 +269,8 @@ class BaseView(GenericView): @Lazy def versionInfo(self): + if not self.useVersioning: + return None context = self.context versionable = IVersionable(context, None) if versionable is None: diff --git a/browser/concept_macros.pt b/browser/concept_macros.pt index 74d805a..9bac39c 100644 --- a/browser/concept_macros.pt +++ b/browser/concept_macros.pt @@ -87,7 +87,8 @@ Title Type - V + V Size Modification Date @@ -103,13 +104,15 @@ Type - - 1.1 - + + + 1.1 + + Type diff --git a/browser/node.py b/browser/node.py index 5bd64ad..134869d 100644 --- a/browser/node.py +++ b/browser/node.py @@ -584,6 +584,17 @@ class ViewPropertiesConfigurator(object): return setting.get('skinName', {}).get('value', '') skinName = property(getSkinName, setSkinName) + def setOptions(self, options): + ann = IAnnotations(self.context) + setting = ann.get(configurator.ANNOTATION_KEY, {}) + setting['options'] = {'value': options} + ann[configurator.ANNOTATION_KEY] = setting + def getOptions(self): + ann = IAnnotations(self.context) + setting = ann.get(configurator.ANNOTATION_KEY, {}) + return setting.get('options', {}).get('value', []) + options = property(getOptions, setOptions) + class NodeViewConfigurator(configurator.ViewConfigurator): """ Take properties from next menu item... diff --git a/configure.zcml b/configure.zcml index c366abb..05687ee 100644 --- a/configure.zcml +++ b/configure.zcml @@ -80,7 +80,7 @@ + getResourceManager getViewManager skinName options" /> Title Type - V + V Size Modification Date @@ -66,13 +67,15 @@ tal:content="row/title" /> Type - - 1.1 - + + + 1.1 + + Size