Commit befb65f2 authored by Nicolas Dumazet's avatar Nicolas Dumazet

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
parent e1be838d
...@@ -585,20 +585,20 @@ class BaseTemplateItem(Implicit, Persistent): ...@@ -585,20 +585,20 @@ class BaseTemplateItem(Implicit, Persistent):
""" """
Remove unneeded properties for export Remove unneeded properties for export
""" """
meta_type = getattr(aq_base(obj), 'meta_type', None) klass = obj.__class__
if meta_type == 'Script (Python)': classname = klass.__name__
meta_type = 'ERP5 Python Script'
attr_set = set(('_dav_writelocks', '_filepath', '_owner', 'uid', attr_set = set(('_dav_writelocks', '_filepath', '_owner', 'uid',
'workflow_history', '__ac_local_roles__')) 'workflow_history', '__ac_local_roles__'))
if export: if export:
attr_set.update({ # PythonScript covers both Zope Python scripts
'ERP5 Python Script': (#'func_code', 'func_defaults', '_code', # and ERP5 Python Scripts
'_lazy_compilation', 'Python_magic'), if classname == 'PythonScript':
#'Z SQL Method': ('_arg', 'template',), attr_set.update((#'func_code', 'func_defaults', '_code',
}.get(meta_type, ())) '_lazy_compilation', 'Python_magic'))
#elif classname == 'SQL' and klass.__module__== 'Products.ZSQLMethods':
if interfaces.IIdGenerator.providedBy(obj): # attr_set.update(('_arg', 'template'))
elif interfaces.IIdGenerator.providedBy(obj):
for dict_name in ('last_max_id_dict', 'last_id_dict'): for dict_name in ('last_max_id_dict', 'last_id_dict'):
if getattr(obj, dict_name, None) is not None: if getattr(obj, dict_name, None) is not None:
delattr(obj, dict_name) delattr(obj, dict_name)
...@@ -607,10 +607,10 @@ class BaseTemplateItem(Implicit, Persistent): ...@@ -607,10 +607,10 @@ class BaseTemplateItem(Implicit, Persistent):
if attr in attr_set or attr.startswith('_cache_cookie_'): if attr in attr_set or attr.startswith('_cache_cookie_'):
delattr(obj, attr) delattr(obj, attr)
if meta_type == 'ERP5 PDF Form': if classname == 'PDFForm':
if not obj.getProperty('business_template_include_content', 1): if not obj.getProperty('business_template_include_content', 1):
obj.deletePdfContent() obj.deletePdfContent()
elif meta_type == 'ERP5 Python Script': elif classname == 'PythonScript':
if export: if export:
# XXX forward compatibility: set to None instead of deleting '_code' # XXX forward compatibility: set to None instead of deleting '_code'
# so that old BT code can import recent BT # so that old BT code can import recent BT
......
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