Commit 35bc4bbe authored by Julien Muchembled's avatar Julien Muchembled

More XML clean up for Python Scripts

Now that most erp5_* Business Templates can only be installed on instances using
new portal types as classes, it is possible to enable clean up that was
implemented by commit 38348.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41515 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3d757c05
......@@ -560,11 +560,11 @@ class BaseTemplateItem(Implicit, Persistent):
# PythonScript covers both Zope Python scripts
# and ERP5 Python Scripts
if isinstance(obj, PythonScript):
# XXX forward compatibility: set to None instead of deleting '_code'
# so that old BT code can import recent BT
obj._code = None
attr_set.update((#'func_code', 'func_defaults', '_code',
attr_set.update(('func_code', 'func_defaults', '_code',
'_lazy_compilation', 'Python_magic'))
for attr in 'errors', 'warnings', '_proxy_roles':
if not obj.__dict__.get(attr, 1):
delattr(obj, attr)
#elif classname == 'SQL' and klass.__module__== 'Products.ZSQLMethods':
# attr_set.update(('_arg', 'template'))
elif interfaces.IIdGenerator.providedBy(obj):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Python Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
if len(old_line_list) == 2 and len(new_line_list) == 1 and \\\n
old_line_list[0] == \'<string>append</string>\' and \\\n
old_line_list[1] == \'<string>$append0</string>\' and \\\n
new_line_list[0] ==\'<string>$list0</string>\':\n
return True\n
\n
return False\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>old_line_list, new_line_list</string> </value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>callable_type/script/diff_filter</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string encoding="cdata"><![CDATA[
This script filter this kind of xml changes :\n
- <string>append</string>\n
- <string>$append0</string>\n
+ <string>$list0</string>\n
]]></string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>old_line_list</string>
<string>new_line_list</string>
<string>len</string>
<string>_getitem_</string>
<string>True</string>
<string>False</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TemplateTool_filterAppendToListDiff</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Python Script</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
40836
\ No newline at end of file
40837
\ No newline at end of file
......@@ -1271,7 +1271,7 @@ def optimize():
# Delay the compilations of Python Scripts until they are really executed.
from Products.PythonScripts.PythonScript import PythonScript
# In the future, Python Scripts will be exported without those 2 attributes:
# Python Scripts are exported without those 2 attributes:
PythonScript.func_code = lazy_func_prop('func_code', None)
PythonScript.func_defaults = lazy_func_prop('func_defaults', None)
......@@ -1296,19 +1296,6 @@ def optimize():
self._filepath = self.get_filepath()
PythonScript._makeFunction = _makeFunction
# XXX Previous implementation of this 'optimize' function requires that
# Python Scripts always contain up-to-date data for 'func_code' and
# 'func_defaults' properties, so make sure we always export them.
# This compatibility code is not required for normal ERP5 instances
# because scripts are compiled at BT installation.
from Products.ERP5.Document.BusinessTemplate import BaseTemplateItem
BaseTemplateItem_removeProperties = BaseTemplateItem.removeProperties
def removeProperties(self, obj, export):
if export and isinstance(obj, PythonScript):
obj.func_code # trigger compilation if needed
return BaseTemplateItem_removeProperties(self, obj, export)
BaseTemplateItem.removeProperties = removeProperties
# Do not reindex portal types sub objects by default
# We will probably disable reindexing for other types later
full_indexing_set = set(os.environ.get('enable_full_indexing', '').split(','))
......
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