use collective.monkeypatcher to apply patches
This commit is contained in:
parent
e6e42150fd
commit
e3a26b695c
|
@ -4,6 +4,7 @@
|
||||||
xmlns:grok="http://namespaces.zope.org/grok"
|
xmlns:grok="http://namespaces.zope.org/grok"
|
||||||
xmlns:i18n="http://namespaces.zope.org/i18n"
|
xmlns:i18n="http://namespaces.zope.org/i18n"
|
||||||
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
|
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
|
||||||
|
xmlns:monkey="http://namespaces.plone.org/monkey"
|
||||||
i18n_domain="pfwbged.tabellio">
|
i18n_domain="pfwbged.tabellio">
|
||||||
|
|
||||||
<five:registerPackage package="." initialize=".initialize" />
|
<five:registerPackage package="." initialize=".initialize" />
|
||||||
|
@ -18,4 +19,20 @@
|
||||||
provides="Products.GenericSetup.interfaces.EXTENSION"
|
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>
|
</configure>
|
||||||
|
|
|
@ -15,19 +15,16 @@ from . import documents
|
||||||
|
|
||||||
# Monkeypatching of various collective.documentviewer parts
|
# 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
|
# don't check permissions for tabellio thumbnails; this would otherwise
|
||||||
# require the objects to have a stable UID and to be registered in the
|
# require the objects to have a stable UID and to be registered in the
|
||||||
# catalog.
|
# catalog.
|
||||||
def publishTraverse(self, request, name):
|
if name.endswith('-noisrev-tabellio'):
|
||||||
if name.endswith('-noisrev-tabellio'):
|
fi = DirectoryResource.publishTraverse(self, request, name)
|
||||||
fi = DirectoryResource.publishTraverse(self, request, name)
|
return fi
|
||||||
return fi
|
return self._old_publishTraverse(request, name)
|
||||||
return super(PDFFiles, self).publishTraverse(request, name)
|
|
||||||
|
|
||||||
|
def patched_base_init(self, context):
|
||||||
orig_init = collective.documentviewer.settings.Base.__init__
|
|
||||||
def base_init(self, context):
|
|
||||||
# for our transient files we cannot store documentviewer information in
|
# for our transient files we cannot store documentviewer information in
|
||||||
# the object annotations so we have to create them under varying names
|
# the object annotations so we have to create them under varying names
|
||||||
# in the DocumentsFolder object.
|
# in the DocumentsFolder object.
|
||||||
|
@ -43,13 +40,10 @@ def base_init(self, context):
|
||||||
self.storage_version = collective.documentviewer.settings.STORAGE_VERSION
|
self.storage_version = collective.documentviewer.settings.STORAGE_VERSION
|
||||||
annotations['collective.documentviewer-%s' % context.id] = self._metadata
|
annotations['collective.documentviewer-%s' % context.id] = self._metadata
|
||||||
else:
|
else:
|
||||||
orig_init(self, context)
|
self._old___init__(context)
|
||||||
|
|
||||||
|
|
||||||
def patchDocumentViewer():
|
def patchDocumentViewer():
|
||||||
collective.documentviewer.views.PDFFiles = PDFFiles
|
|
||||||
collective.documentviewer.settings.Base.__init__ = base_init
|
|
||||||
collective.documentviewer.convert.Converter.isIndexationEnabled = lambda x: True
|
collective.documentviewer.convert.Converter.isIndexationEnabled = lambda x: True
|
||||||
|
|
||||||
# avoid streaming files as the blob hack breaks this
|
# avoid streaming files as the blob hack breaks this
|
||||||
plone.namedfile.utils.filestream_iterator = None
|
plone.namedfile.utils.filestream_iterator = None
|
||||||
|
|
Reference in New Issue