summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2015-01-27 12:37:17 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2015-01-27 12:37:17 (GMT)
commite3a26b695c77c06544e2e427bc034b8626ee08dd (patch)
tree77c1f58b0b5984a2aa66435fefdc36e2226e16af
parente6e42150fd4d8956db9b5ecdab09956ad18e8b7a (diff)
downloadpfwbged.tabellio-master.zip
pfwbged.tabellio-master.tar.gz
pfwbged.tabellio-master.tar.bz2
use collective.monkeypatcher to apply patchesHEADmaster
-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