summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pfwbged/tabellio/configure.zcml17
-rw-r--r--src/pfwbged/tabellio/monkey.py20
2 files changed, 24 insertions, 13 deletions
diff --git a/src/pfwbged/tabellio/configure.zcml b/src/pfwbged/tabellio/configure.zcml
index 548ad16..0037f3b 100644
--- a/src/pfwbged/tabellio/configure.zcml
+++ b/src/pfwbged/tabellio/configure.zcml
@@ -4,6 +4,7 @@
xmlns:grok="http://namespaces.zope.org/grok"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
+ xmlns:monkey="http://namespaces.plone.org/monkey"
i18n_domain="pfwbged.tabellio">
<five:registerPackage package="." initialize=".initialize" />
@@ -18,4 +19,20 @@
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
+ <monkey:patch
+ description="Don't check permissions for Tabellio thumbnails"
+ class="collective.documentviewer.views.PDFFiles"
+ original="publishTraverse"
+ preserveOriginal="true"
+ replacement=".monkey.patched_publishTraverse"
+ />
+
+ <monkey:patch
+ description="Store annotations in base Tabellio folder"
+ class="collective.documentviewer.settings.Base"
+ original="__init__"
+ preserveOriginal="true"
+ replacement=".monkey.patched_base_init"
+ />
+
</configure>
diff --git a/src/pfwbged/tabellio/monkey.py b/src/pfwbged/tabellio/monkey.py
index 5d59c49..4cd424d 100644
--- a/src/pfwbged/tabellio/monkey.py
+++ b/src/pfwbged/tabellio/monkey.py
@@ -15,19 +15,16 @@ from . import documents
# Monkeypatching of various collective.documentviewer parts
-class PDFFiles(collective.documentviewer.views.PDFFiles):
+def patched_publishTraverse(self, request, name):
# don't check permissions for tabellio thumbnails; this would otherwise
# require the objects to have a stable UID and to be registered in the
# catalog.
- def publishTraverse(self, request, name):
- if name.endswith('-noisrev-tabellio'):
- fi = DirectoryResource.publishTraverse(self, request, name)
- return fi
- return super(PDFFiles, self).publishTraverse(request, name)
+ if name.endswith('-noisrev-tabellio'):
+ fi = DirectoryResource.publishTraverse(self, request, name)
+ return fi
+ return self._old_publishTraverse(request, name)
-
-orig_init = collective.documentviewer.settings.Base.__init__
-def base_init(self, context):
+def patched_base_init(self, context):
# for our transient files we cannot store documentviewer information in
# the object annotations so we have to create them under varying names
# in the DocumentsFolder object.
@@ -43,13 +40,10 @@ def base_init(self, context):
self.storage_version = collective.documentviewer.settings.STORAGE_VERSION
annotations['collective.documentviewer-%s' % context.id] = self._metadata
else:
- orig_init(self, context)
+ self._old___init__(context)
def patchDocumentViewer():
- collective.documentviewer.views.PDFFiles = PDFFiles
- collective.documentviewer.settings.Base.__init__ = base_init
collective.documentviewer.convert.Converter.isIndexationEnabled = lambda x: True
-
# avoid streaming files as the blob hack breaks this
plone.namedfile.utils.filestream_iterator = None