Commit 5a8d4f81 authored by Julien Muchembled's avatar Julien Muchembled

Make XML representation of BT more stable:

* Fixes the problem related to indendation. Indentation spaces mustn't be kept in cache (Immutable).
* Really remove '_filepath', '_owner', 'uid' and '__ac_local_roles__' attributes instead of setting them to None when they are defined on the object.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23576 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f1eb1007
......@@ -446,34 +446,23 @@ class BaseTemplateItem(Implicit, Persistent):
"""
Remove unneeded properties for export
"""
_marker = []
base_obj = aq_base(obj)
if getattr(base_obj, '_dav_writelocks', _marker) is not _marker:
del aq_base(obj)._dav_writelocks
if getattr(base_obj, '__ac_local_roles__', _marker) is not _marker:
# remove local roles
obj.__ac_local_roles__ = None
if getattr(base_obj, '_owner', _marker) is not _marker:
obj._owner = None
if getattr(base_obj, 'uid', _marker) is not _marker:
obj.uid = None
if getattr(base_obj, '_filepath', _marker) is not _marker:
obj._filepath = None
if getattr(base_obj, 'workflow_history', _marker) is not _marker:
if getattr(base_obj.__class__, 'workflow_history', _marker) \
is not _marker:
obj.workflow_history = None
else:
del obj.workflow_history
if getattr(base_obj, 'meta_type', None) == 'Script (Python)':
if getattr(base_obj, '_code', _marker) is not _marker:
obj._code = None
if getattr(base_obj, 'Python_magic', _marker) is not _marker:
obj.Python_magic = None
elif getattr(base_obj, 'meta_type', None) == 'ERP5 PDF Form' :
if not obj.getProperty('business_template_include_content', 1) :
meta_type = getattr(aq_base(obj), 'meta_type', None)
attr_list = [ '_dav_writelocks', '_filepath', '_owner', 'uid',
'workflow_history', '__ac_local_roles__' ]
attr_list += {
'Script (Python)': ('_lazy_compilation', 'Python_magic'),
}.get(meta_type, ())
for attr in attr_list:
if attr in obj.__dict__:
delattr(obj, attr)
if meta_type == 'ERP5 PDF Form':
if not obj.getProperty('business_template_include_content', 1):
obj.deletePdfContent()
elif meta_type == 'Script (Python)':
obj._code = None
return obj
class ObjectTemplateItem(BaseTemplateItem):
......
......@@ -95,13 +95,12 @@ class String(Scalar):
# JPS repr is default encoding
encoding=' encoding="%s"' % self.encoding
name=string.lower(self.__class__.__name__)
result = '%s<%s%s%s>%s</%s>\n' % (
' '*indent, name, id, encoding, v, name)
result = '<%s%s%s>%s</%s>' % (name, id, encoding, v, name)
if hasattr(self, 'id'):
# The value is Immutable - let us add it the the immutable mapping
# to reduce the number of unreadable references
self.mapping.setImmutable(self.id, Immutable(value = result))
return result
return '%s%s\n' % (' '*indent, result)
ppml.String = String
......@@ -224,13 +223,15 @@ class Reference(Scalar):
self.mapping = mapping
def __str__(self, indent=0):
v=self._v
name=string.lower(self.__class__.__name__)
#LOG('Reference', 0, str(v))
if self.mapping.hasImmutable(v):
return self.mapping.getImmutable(v).getValue()
value = self.mapping.getImmutable(v).getValue()
else:
name = self.__class__.__name__.lower()
#LOG('noImmutable', 0, "%s mapped to %s" % (v, self.mapping[v]))
self.mapping.mark(v)
return '%s<%s id="%s"/>\n' % (' '*indent,name,self.mapping[v])
value = '<%s id="%s"/>' % (name, self.mapping[v])
return '%s%s\n' % (' '*indent, value)
ppml.Reference = Reference
Get = Reference
......
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