Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
erp5
Commits
0571cbab
Commit
0571cbab
authored
May 05, 2015
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forge: add business template diff tool without git dependencies
parent
b150514c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
247 additions
and
0 deletions
+247
-0
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_reportUpgraderBusinessTemplateDiff.xml
.../erp5_toolbox/Base_reportUpgraderBusinessTemplateDiff.xml
+109
-0
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getDiffWithZODBAsText.xml
...s/erp5_toolbox/BusinessTemplate_getDiffWithZODBAsText.xml
+138
-0
No files found.
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_reportUpgraderBusinessTemplateDiff.xml
0 → 100644
View file @
0571cbab
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</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>
# This script comes with Base_gitDiffWithZODBAsText.\n
# It should be ran in an alarm thank to a property sheet constraint.\n
# Where does this script should be commited?\n
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery\n
\n
if fixit:\n
return ["Cannot fix automatically, please do it manually. (Or deactivate the constraint to force upgrade.)"]\n
\n
portal = context.getPortalObject()\n
\n
bt_title_list, keep_bt_title_list = context.Base_getUpgradeBusinessTemplateList()\n
keep_bt_title_set = set(keep_bt_title_list)\n
bt_title_list = [\n
title\n
for _, title in portal.portal_templates.resolveBusinessTemplateListDependency(bt_title_list)\n
if title not in keep_bt_title_set\n
]\n
\n
bt_list = [\n
bt\n
for bt in portal.portal_catalog(\n
portal_type="Business Template",\n
query=SimpleQuery(title=bt_title_list, comparison_operator=\'=\'),\n
)\n
if bt.getInstallationState() == "installed"\n
]\n
\n
#bt_list = [\n
# x.getObject()\n
# for x in portal.portal_catalog(\n
# portal_type="Business Template",\n
# installation_state="installed",\n
# )\n
# if x.getInstallationState() == "installed"\n
#]\n
\n
diff_list = []\n
for bt in bt_list:\n
diff = bt.BusinessTemplate_getDiffWithZODBAsText()\n
if diff:\n
diff_list += ["===== %s =====" % bt.getTitle()] + diff.splitlines()\n
\n
return diff_list\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
fixit=False, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_reportUpgraderBusinessTemplateDiff
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getDiffWithZODBAsText.xml
0 → 100644
View file @
0571cbab
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</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[
# This script comes with Base_reportUpgraderBunisessTemplateDiff.\n
# It can be ran individualy, of course.\n
# Where does this script should be commited? erp5_core?\n
# This diff script clones and builds it\'s own bt for comparision,\n
# check with other script why this is not already done. Like on\n
# TemplateTool_getDetailedDiff in erp5_core portal skin.\n
from Products.ERP5Type.Document import newTempBase\n
from ZODB.POSException import ConflictError\n
\n
template_tool = context.getPortalObject().portal_templates\n
\n
assert context.getBuildingState() == "built", "%s != \'built\'" % repr(context.getBuildingState())\n
\n
def getDiffObjectList(business_template, installed_bt_for_diff):\n
# business_template is assumed built and installed\n
modified_object_list = business_template.preinstall(check_dependencies=0, compare_to=installed_bt_for_diff)\n
keys = modified_object_list.keys()\n
#keys.sort() # XXX don\'t care ?\n
bt_id = business_template.getId()\n
i = 0\n
object_list = []\n
for object_id in keys:\n
object_state, object_class = modified_object_list[object_id]\n
line = newTempBase(template_tool, \'tmp_install_%s\' % (str(i))) # template_tool or context?\n
line.edit(object_id=object_id, object_state=object_state, object_class=object_class, bt1=bt_id, bt2=bt_id)\n
line.setUid(\'new_%s\' % object_id)\n
object_list.append(line)\n
i += 1\n
return object_list\n
\n
def getSortedDiffObjectList(business_template, installed_bt_for_diff):\n
return sorted(\n
sorted(\n
getDiffObjectList(business_template, installed_bt_for_diff),\n
key=lambda x: x.object_id\n
),\n
key=lambda x: x.object_state\n
)\n
\n
\n
try:\n
installed_bt_for_diff = context.Base_createCloneDocument(clone=1, batch_mode=1)\n
except ConflictError:\n
raise\n
except Exception as e:\n
print(e)\n
return printed #.split("\\n")\n
\n
name = "installed_bt_for_diff"\n
try:\n
installed_bt_for_diff.setId(name)\n
installed_bt_for_diff.build()\n
for diff_object in getSortedDiffObjectList(context, installed_bt_for_diff):\n
print("%s (%s) ->
%s" % (diff_object.object_state, diff_object.object_class, diff_object.object_id))\n
# Just uncomment these lines below to append diff to the text\n
#if diff_object.object_state != "Modified":\n
# continue\n
#print(context.diffObject(diff_object, compare_with=name).lstrip())\n
#print("")\n
except ConflictError:\n
raise\n
except Exception as e:\n
print(e)\n
finally:\n
template_tool.manage_delObjects(ids=[installed_bt_for_diff.getId()])\n
\n
#return "
<pre>
" + printed.replace("
&
", "
&
").replace("
<
", "
<
").replace(">", "
>
").replace("\\"", "
"
") + "
</pre>
"\n
return printed #.split("\\n")\n
]]>
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
BusinessTemplate_getDiffWithZODBAsText
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment