diff --git a/browser/common.py b/browser/common.py index c41a76b..990093b 100644 --- a/browser/common.py +++ b/browser/common.py @@ -69,7 +69,7 @@ from loops.resource import Resource from loops.security.common import canAccessObject, canListObject, canWriteObject from loops.type import ITypeConcept from loops import util -from loops.util import _ +from loops.util import _, saveRequest from loops import version from loops.versioning.interfaces import IVersionable @@ -145,6 +145,7 @@ class BaseView(GenericView, I18NView): raise Unauthorized(str(self.contextInfo)) except ForbiddenAttribute: # ignore when testing pass + saveRequest(request) def checkPermissions(self): return canAccessObject(self.context) diff --git a/compound/book/browser.py b/compound/book/browser.py index 533e12d..6b55e5f 100644 --- a/compound/book/browser.py +++ b/compound/book/browser.py @@ -41,6 +41,10 @@ book_template = ViewPageTemplateFile('view_macros.pt') class Base(object): + @Lazy + def book_macros(self): + return book_template.macros + @Lazy def isPartOfPredicate(self): return self.conceptManager['ispartof'] @@ -50,6 +54,29 @@ class Base(object): for p in self.context.getParents([self.isPartOfPredicate]): return self.nodeView.getViewForTarget(p) + @Lazy + def neighbours(self): + pred = succ = None + parent = self.breadcrumbsParent + if parent is not None: + myself = None + children = list(parent.context.getChildren([self.isPartOfPredicate])) + for idx, c in enumerate(children): + if c == self.context: + if idx > 0: + pred = self.nodeView.getViewForTarget(children[idx-1]) + if idx < len(children) - 1: + succ = self.nodeView.getViewForTarget(children[idx+1]) + return pred, succ + + @Lazy + def predecessor(self): + return self.neighbours[0] + + @Lazy + def successor(self): + return self.neighbours[1] + @Lazy def tabview(self): if self.editable: @@ -73,6 +100,10 @@ class SectionView(Base, ConceptView): def documentTypeType(self): return self.conceptManager['documenttype'] + @Lazy + def showNavigation(self): + return self.typeOptions.show_navigation + @Lazy def sectionType(self): return self.conceptManager['section'] diff --git a/compound/book/view_macros.pt b/compound/book/view_macros.pt index cef53c2..0431662 100644 --- a/compound/book/view_macros.pt +++ b/compound/book/view_macros.pt @@ -13,6 +13,24 @@ + +
+ + + + + + +
+
@@ -57,6 +75,9 @@
+
+ +
diff --git a/integrator/office/base.py b/integrator/office/base.py index 67fe4bc..bed343b 100644 --- a/integrator/office/base.py +++ b/integrator/office/base.py @@ -78,15 +78,16 @@ class OfficeFile(ExternalFileAdapter): @Lazy def docPropertyDom(self): fn = self.docFilename + dummy = dict(core=[], custom=[]) root, ext = os.path.splitext(fn) if not ext.lower() in self.fileExtensions: - return [] + return dummy try: zf = ZipFile(fn, 'r') except IOError, e: from logging import getLogger self.logger.warn(e) - return [] + return dummy if self.corePropFileName not in zf.namelist(): self.logger.warn('Core properties not found in file %s.' % self.externalAddress) diff --git a/knowledge/browser.py b/knowledge/browser.py index 8a7a281..fd9a8ed 100644 --- a/knowledge/browser.py +++ b/knowledge/browser.py @@ -61,7 +61,7 @@ actions.register('editTopic', 'portlet', DialogAction, actions.register('createQualification', 'portlet', DialogAction, title=_(u'Create Qualification Record...'), - description=_(u'Create a work item for this person.'), + description=_(u'Create a qualification record for this person.'), viewName='create_qualification.html', dialogName='createQualification', prerequisites=['registerDojoDateWidget', 'registerDojoNumberWidget', diff --git a/util.py b/util.py index 0206bfc..45e13a8 100644 --- a/util.py +++ b/util.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2011 Helmut Merz helmutm@cy55.de +# Copyright (c) 2012 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,8 +18,6 @@ """ Utility functions. - -$Id$ """ import os @@ -28,6 +26,7 @@ from zope.interface import directlyProvides, directlyProvidedBy from zope.intid.interfaces import IIntIds from zope.i18nmessageid import MessageFactory from zope.schema import vocabulary +from zope import thread import cybertools from loops.browser.util import html_quote @@ -134,3 +133,12 @@ def getLogDirectory(request=None): return os.path.join(os.path.dirname(varDir), 'log') +# store thread-local stuff + +local_data = thread.local() + +def saveRequest(request): + local_data.request = request + +def getRequest(): + return local_data.request