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