From befb65f2c47fa59c4a0a144b3ce0323c4635ce01 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Thu, 23 Sep 2010 18:06:40 +0000 Subject: [PATCH] Use classes instead of meta types to determine attribute cleanup conditions. It does not necessarily requires us to load the object. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38601 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/BusinessTemplate.py | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index d844c90fa7..3407b5b8c8 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -585,20 +585,20 @@ class BaseTemplateItem(Implicit, Persistent): """ 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, Persistent): 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 -- 2.30.9