[Erp5-report] r23576 - in /erp5/trunk/products: ERP5/Document/ ERP5Type/patches/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Sep 11 20:28:14 CEST 2008
Author: jm
Date: Thu Sep 11 20:28:12 2008
New Revision: 23576
URL: http://svn.erp5.org?rev=23576&view=rev
Log:
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.
Modified:
erp5/trunk/products/ERP5/Document/BusinessTemplate.py
erp5/trunk/products/ERP5Type/patches/ppml.py
Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=23576&r1=23575&r2=23576&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py Thu Sep 11 20:28:12 2008
@@ -446,34 +446,23 @@
"""
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):
Modified: erp5/trunk/products/ERP5Type/patches/ppml.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/ppml.py?rev=23576&r1=23575&r2=23576&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/ppml.py (original)
+++ erp5/trunk/products/ERP5Type/patches/ppml.py Thu Sep 11 20:28:12 2008
@@ -95,13 +95,12 @@
# 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 @@
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()
- #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 = 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)
+ value = '<%s id="%s"/>' % (name, self.mapping[v])
+ return '%s%s\n' % (' '*indent, value)
ppml.Reference = Reference
Get = Reference
More information about the Erp5-report
mailing list