Commit 326a1655 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP

parent e78ac944
...@@ -97,11 +97,7 @@ from warnings import warn ...@@ -97,11 +97,7 @@ from warnings import warn
from lxml.etree import parse from lxml.etree import parse
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
import six from urllib.parse import quote, unquote
if six.PY2:
from urllib.parse import quote, unquote
else:
from urllib.parse import quote_from_bytes as quote, unquote_to_bytes as unquote
from difflib import unified_diff from difflib import unified_diff
import posixpath import posixpath
import transaction import transaction
...@@ -1042,7 +1038,7 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -1042,7 +1038,7 @@ class ObjectTemplateItem(BaseTemplateItem):
F.binary=1 F.binary=1
F.file=outfile F.file=outfile
p=xml.parsers.expat.ParserCreate('utf-8') p=xml.parsers.expat.ParserCreate('utf-8')
p.returns_unicode = False p.buffer_text = True
p.CharacterDataHandler=F.handle_data p.CharacterDataHandler=F.handle_data
p.StartElementHandler=F.unknown_starttag p.StartElementHandler=F.unknown_starttag
p.EndElementHandler=F.unknown_endtag p.EndElementHandler=F.unknown_endtag
...@@ -5928,11 +5924,12 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -5928,11 +5924,12 @@ Business Template is a set of definitions, such as skins, portal types and categ
prop_type = prop['type'] prop_type = prop['type']
value = bt_item.get(pid) value = bt_item.get(pid)
if prop_type in ('text', 'string'): if prop_type in ('text', 'string'):
prop_dict[pid] = value or '' prop_dict[pid] = value.decode('utf-8') if value else ''
elif prop_type in ('int', 'boolean'): elif prop_type in ('int', 'boolean'):
prop_dict[pid] = value or 0 prop_dict[pid] = value or 0
elif prop_type in ('lines', 'tokens'): elif prop_type in ('lines', 'tokens'):
prop_dict[pid[:-5]] = (value or '').splitlines() prop_dict[pid[:-5]] = (value.decode('utf-8') if value
else '').splitlines()
self._edit(**prop_dict) self._edit(**prop_dict)
try: try:
......
...@@ -53,7 +53,7 @@ SECURITY_PARAMETER_ID = 'local_roles' ...@@ -53,7 +53,7 @@ SECURITY_PARAMETER_ID = 'local_roles'
from AccessControl.SecurityInfo import ModuleSecurityInfo from AccessControl.SecurityInfo import ModuleSecurityInfo
ModuleSecurityInfo(__name__).declarePublic('SECURITY_PARAMETER_ID') ModuleSecurityInfo(__name__).declarePublic('SECURITY_PARAMETER_ID')
class WorkflowTool(BaseTool, OriginalWorkflowTool): class WorkflowTool(BaseTool):
""" """
A new container for DC workflow and workflow; A new container for DC workflow and workflow;
inherits methods from original WorkflowTool.py; inherits methods from original WorkflowTool.py;
...@@ -75,6 +75,21 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -75,6 +75,21 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
'DublinCore', 'DublinCore',
) )
def _isBootstrapRequired(self):
"""
Required by synchronizeDynamicModules() to bootstrap an empty site and
thus create portal_components
"""
return False
def _bootstrap(self):
"""
Required by synchronizeDynamicModules() to bootstrap an empty site and
thus create portal_components
"""
pass
def filtered_meta_types(self, user=None): def filtered_meta_types(self, user=None):
return False return False
......
...@@ -421,10 +421,11 @@ class ComponentDynamicPackage(ModuleType): ...@@ -421,10 +421,11 @@ class ComponentDynamicPackage(ModuleType):
# load_module(), and returning module 'name' in contrary to __import__ # load_module(), and returning module 'name' in contrary to __import__
# returning 'erp5' (requiring fromlist parameter which is slower) # returning 'erp5' (requiring fromlist parameter which is slower)
return import_module(fullname) return import_module(fullname)
except ModuleNotFoundError: # >= 3.6
pass
except ImportError as e: except ImportError as e:
if str(e) != "No module named " + name: LOG("ERP5Type.dynamic", WARNING,
LOG("ERP5Type.dynamic", WARNING, "Could not load Component module %r" % fullname, error=True)
"Could not load Component module %r" % fullname, error=True)
return None return None
......
...@@ -83,7 +83,7 @@ def unconvert(encoding,S): ...@@ -83,7 +83,7 @@ def unconvert(encoding,S):
if encoding == 'base64': if encoding == 'base64':
return base64.decodestring(S) return base64.decodestring(S)
else: else:
return eval("'" + S.replace('\n', '') + "'") return bytes(eval(b"'" + S.replace(b'\n', b'') + b"'"), 'utf-8')
ppml.unconvert = unconvert ppml.unconvert = unconvert
...@@ -671,31 +671,28 @@ class ToXMLUnpickler(Unpickler): ...@@ -671,31 +671,28 @@ class ToXMLUnpickler(Unpickler):
ppml.ToXMLUnpickler = ToXMLUnpickler ppml.ToXMLUnpickler = ToXMLUnpickler
def save_string(self, tag, data): def save_string(self, tag, data):
binary=self.binary a = data[1]
v='' v = b''.join(data[2:])
a=data[1] encoding = a.get('encoding', 'repr') # JPS: repr is default encoding
if len(data)>2:
v = ''.join(data[2:])
encoding=a.get('encoding','repr') # JPS: repr is default encoding
if encoding is not '': if encoding is not '':
v=unconvert(encoding,v) v = unconvert(encoding, v)
put='p' if self.binary:
if binary: l = len(v)
l=len(v) if l < 256:
s=mdumps(l)[1:] if isinstance(v, str):
if (l<256): import pdb; pdb.set_trace()
v='U'+s[0]+v v = SHORT_BINSTRING + bytes([l]) + v
else: else:
v='T'+s+v v = BINSTRING + struct.pack('<i', l) + v
put='q' else:
else: v="S'"+v+"'\012" v = STRING + repr(v) + '\n'
return save_put(self, v, a) return save_put(self, v, a)
ppml.save_string = save_string ppml.save_string = save_string
def save_unicode(self, tag, data): def save_unicode(self, tag, data):
binary=self.binary binary=self.binary
v='' v=b''
a=data[1] a=data[1]
if len(data)>2: if len(data)>2:
for x in data[2:]: for x in data[2:]:
...@@ -715,20 +712,20 @@ ppml.save_unicode = save_unicode ...@@ -715,20 +712,20 @@ ppml.save_unicode = save_unicode
def save_object(self, tag, data): def save_object(self, tag, data):
if len(data)==5: if len(data)==5:
#OBJECT #OBJECT
v='('+data[2] v=b'('+data[2]
x=data[3][1:] x=data[3][1:]
stop=x.rfind('t') # This seems stop=x.rfind(b't') # This seems
if stop>=0: x=x[:stop] # wrong! if stop>=0: x=x[:stop] # wrong!
v=save_put(self, v+x+'o', data[1]) v=save_put(self, v+x+b'o', data[1])
v=v+data[4]+'b' # state v=v+data[4]+b'b' # state
return v return v
else: else:
#REDUCE #REDUCE
#data does not contain state.(See Object.__setstate__ definition) #data does not contain state.(See Object.__setstate__ definition)
#So, we can assume that this is a reduce. (Yusei) #So, we can assume that this is a reduce. (Yusei)
v='('+data[2] v=b'('+data[2]
v=save_put(self, data[2]+data[3], data[1]) v=save_put(self, data[2]+data[3], data[1])
v=v+'R' v=v+b'R'
return v return v
ppml.save_object = save_object ppml.save_object = save_object
...@@ -737,16 +734,16 @@ def save_pickle_start(self, tag, attrs): ...@@ -737,16 +734,16 @@ def save_pickle_start(self, tag, attrs):
return [tag, attrs] return [tag, attrs]
def save_pickle(self, tag, data): def save_pickle(self, tag, data):
return data[2] + '.' return data[2] + b'.'
def save_none(self, tag, data): def save_none(self, tag, data):
return 'N' return b'N'
def save_long(self, tag, data): def save_long(self, tag, data):
return 'L'+data[2]+'L\012' return b'L'+data[2]+b'L\012'
def save_item(self, tag, data): def save_item(self, tag, data):
return ''.join(data[2:]) return b''.join(data[2:])
def save_value(self, tag, data): def save_value(self, tag, data):
return data[2] return data[2]
...@@ -819,7 +816,7 @@ def importXML(jar, file, clue=''): ...@@ -819,7 +816,7 @@ def importXML(jar, file, clue=''):
# So we have to declare an encoding but not use unicode, so the unpickler # So we have to declare an encoding but not use unicode, so the unpickler
# can deal with the utf-8 strings directly # can deal with the utf-8 strings directly
p=xml.parsers.expat.ParserCreate('utf-8') p=xml.parsers.expat.ParserCreate('utf-8')
p.returns_unicode = False # p.returns_unicode = False
# </patch> # </patch>
p.CharacterDataHandler=F.handle_data p.CharacterDataHandler=F.handle_data
p.StartElementHandler=F.unknown_starttag p.StartElementHandler=F.unknown_starttag
......
...@@ -457,7 +457,7 @@ class DB(TM): ...@@ -457,7 +457,7 @@ class DB(TM):
return items, result return items, result
def string_literal(self, s): def string_literal(self, s):
return self.db.string_literal(s) return self.db.string_literal(s).decode('utf-8')
def _begin(self, *ignored): def _begin(self, *ignored):
"""Begin a transaction (when TM is enabled).""" """Begin a transaction (when TM is enabled)."""
......
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