Commit d0cbf874 authored by Jérome Perrin's avatar Jérome Perrin

HACK: pypdf compatibility patch

We no longer use pypdf but use pypdf2, due to some bugs, we have some
pypdf objects in object database, so create a fake module so that we can
load them.

In a prefious version of this patch we have left some
Products.ERP5.NameObject in the database and saving new version of the
docuement (edit) fails with:
PicklingError: Can't pickle <class 'Products.ERP5.NameObject'>:
attribute lookup Products.ERP5.NameObject failed
parent 27e51354
......@@ -98,3 +98,19 @@ def initialize( context ):
# backward compatibility names
XML = None
UI = None
# pyPdf has been replaced by pyPdf2, but there was https://nexedi.erp5.net/bug_module/20141204-33F729
try:
import pyPdf
except ImportError:
class pyPdfGeneric:
class NameObject(str):
pass
# XXX Seems both generic and Generic existed.
sys.modules['pyPdf.Generic'] = pyPdfGeneric
sys.modules['pyPdf.generic'] = pyPdfGeneric
sys.modules['pyPdf'] = pyPdfGeneric
# XXX previous version of this patch made that some documents have an instance of Products.ERP5.NameObject
NameObject = pyPdfGeneric.NameObject
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment