[Erp5-report] r38601 nicolas.dumazet - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Sep 23 20:06:40 CEST 2010


Author: nicolas.dumazet
Date: Thu Sep 23 20:06:40 2010
New Revision: 38601

URL: http://svn.erp5.org?rev=38601&view=rev
Log:
Use classes instead of meta types to determine attribute cleanup conditions.
It does not necessarily requires us to load the object.

Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=38601&r1=38600&r2=38601&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Thu Sep 23 20:06:40 2010
@@ -585,20 +585,20 @@ class BaseTemplateItem(Implicit, Persist
     """
     Remove unneeded properties for export
     """
-    meta_type = getattr(aq_base(obj), 'meta_type', None)
-    if meta_type == 'Script (Python)':
-      meta_type = 'ERP5 Python Script'
+    klass = obj.__class__
+    classname = klass.__name__
 
     attr_set = set(('_dav_writelocks', '_filepath', '_owner', 'uid',
                     'workflow_history', '__ac_local_roles__'))
     if export:
-      attr_set.update({
-        'ERP5 Python Script': (#'func_code', 'func_defaults', '_code',
-                               '_lazy_compilation', 'Python_magic'),
-        #'Z SQL Method': ('_arg', 'template',),
-      }.get(meta_type, ()))
-
-      if interfaces.IIdGenerator.providedBy(obj):
+      # PythonScript covers both Zope Python scripts
+      # and ERP5 Python Scripts
+      if classname == 'PythonScript':
+        attr_set.update((#'func_code', 'func_defaults', '_code',
+                         '_lazy_compilation', 'Python_magic'))
+      #elif classname == 'SQL' and klass.__module__== 'Products.ZSQLMethods':
+      #  attr_set.update(('_arg', 'template'))
+      elif interfaces.IIdGenerator.providedBy(obj):
         for dict_name in ('last_max_id_dict', 'last_id_dict'):
           if getattr(obj, dict_name, None) is not None:
             delattr(obj, dict_name)
@@ -607,10 +607,10 @@ class BaseTemplateItem(Implicit, Persist
       if attr in attr_set or attr.startswith('_cache_cookie_'):
         delattr(obj, attr)
 
-    if meta_type == 'ERP5 PDF Form':
+    if classname == 'PDFForm':
       if not obj.getProperty('business_template_include_content', 1):
         obj.deletePdfContent()
-    elif meta_type == 'ERP5 Python Script':
+    elif classname == 'PythonScript':
       if export:
         # XXX forward compatibility: set to None instead of deleting '_code'
         #     so that old BT code can import recent BT




More information about the Erp5-report mailing list