Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
c283984e
Commit
c283984e
authored
Jul 17, 2015
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_forge: add some tools in erp5_toolbox
parent
59100d94
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
373 additions
and
33 deletions
+373
-33
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_reportInstalledBusinessTemplateModification.xml
...lbox/Base_reportInstalledBusinessTemplateModification.xml
+90
-0
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_reportUpgraderBusinessTemplateDiff.xml
.../erp5_toolbox/Base_reportUpgraderBusinessTemplateDiff.xml
+3
-13
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getPrintableDiffWithZODB.xml
...rp5_toolbox/BusinessTemplate_getPrintableDiffWithZODB.xml
+14
-20
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getPrintableModificationListFromZODB.xml
...BusinessTemplate_getPrintableModificationListFromZODB.xml
+127
-0
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Folder_resolvePath.xml
...lateItem/portal_skins/erp5_toolbox/Folder_resolvePath.xml
+139
-0
No files found.
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_reportInstalledBusinessTemplateModification.xml
0 → 100644
View file @
c283984e
<?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>
# It should be ran in an alarm thank to a property sheet constraint.\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
black_list = getattr(context, "Base_getInstalledBusinessTemplateBlackListForModificationList", lambda: ())()\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" and x.getTitle() not in black_list and x.getId() not in black_list\n
]\n
\n
diff_list = []\n
for bt in bt_list:\n
diff = bt.BusinessTemplate_getPrintableModificationListFromZODB()\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_reportInstalledBusinessTemplateModification
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_reportUpgraderBusinessTemplateDiff.xml
View file @
c283984e
...
@@ -50,9 +50,8 @@
...
@@ -50,9 +50,8 @@
</item>
</item>
<item>
<item>
<key>
<string>
_body
</string>
</key>
<key>
<string>
_body
</string>
</key>
<value>
<string>
# This script comes with Base_gitDiffWithZODBAsText.\n
<value>
<string>
# It should be ran in an alarm thank to a property sheet constraint.\n
# It should be ran in an alarm thank to a property sheet constraint.\n
\n
# Where does this script should be commited?\n
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery\n
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery\n
\n
\n
if fixit:\n
if fixit:\n
...
@@ -77,18 +76,9 @@ bt_list = [\n
...
@@ -77,18 +76,9 @@ bt_list = [\n
if bt.getInstallationState() == "installed"\n
if bt.getInstallationState() == "installed"\n
]\n
]\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
diff_list = []\n
for bt in bt_list:\n
for bt in bt_list:\n
diff = bt.BusinessTemplate_get
DiffWithZODBAsText
()\n
diff = bt.BusinessTemplate_get
PrintableModificationListFromZODB
()\n
if diff:\n
if diff:\n
diff_list += ["===== %s =====" % bt.getTitle()] + diff.splitlines()\n
diff_list += ["===== %s =====" % bt.getTitle()] + diff.splitlines()\n
\n
\n
...
...
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_get
DiffWithZODBAsText
.xml
→
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_get
PrintableDiffWithZODB
.xml
View file @
c283984e
...
@@ -52,9 +52,6 @@
...
@@ -52,9 +52,6 @@
<key>
<string>
_body
</string>
</key>
<key>
<string>
_body
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<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
# 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
# check with other script why this is not already done. Like on\n
# TemplateTool_getDetailedDiff in erp5_core portal skin.\n
# TemplateTool_getDetailedDiff in erp5_core portal skin.\n
...
@@ -63,11 +60,12 @@ from ZODB.POSException import ConflictError\n
...
@@ -63,11 +60,12 @@ from ZODB.POSException import ConflictError\n
\n
\n
template_tool = context.getPortalObject().portal_templates\n
template_tool = context.getPortalObject().portal_templates\n
\n
\n
assert context.getBuildingState() == "built", "%s != \'built\'" % repr(context.getBuildingState())\n
if context.getBuildingState() != "built":\n
return "AssertionError(\\"%s != \'built\'\\",)" % repr(context.getBuildingState())\n
\n
\n
def getDiffObjectList(business_template, installed_bt_for_diff):\n
def getDiffObjectList(business_template, installed_bt_for_diff):\n
# business_template is assumed built and installed\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
modified_object_list =
installed_bt_for_diff.preinstall(check_dependencies=0, compare_to=business_template
)\n
keys = modified_object_list.keys()\n
keys = modified_object_list.keys()\n
#keys.sort() # XXX don\'t care ?\n
#keys.sort() # XXX don\'t care ?\n
bt_id = business_template.getId()\n
bt_id = business_template.getId()\n
...
@@ -97,29 +95,25 @@ try:\n
...
@@ -97,29 +95,25 @@ try:\n
except ConflictError:\n
except ConflictError:\n
raise\n
raise\n
except Exception as e:\n
except Exception as e:\n
print(
e
)\n
print(
repr(e)
)\n
return printed
#.split("\\n")
\n
return printed\n
\n
\n
name = "installed_bt_for_diff"\n
try:\n
try:\n
installed_bt_for_diff.setId(
name
)\n
installed_bt_for_diff.setId(
"installed_bt_for_diff"
)\n
installed_bt_for_diff.build()\n
installed_bt_for_diff.build()\n
for diff_object in getSortedDiffObjectList(context, installed_bt_for_diff):\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
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
#if diff_object.object_state != "Modified":\n
continue\n
# continue\n
print(installed_bt_for_diff.diffObject(diff_object, compare_with=context.getId()).lstrip())\n
#print(context.diffObject(diff_object, compare_with=name).lstrip())\n
print("")\n
#print("")\n
except ConflictError:\n
except ConflictError:\n
raise\n
raise\n
except Exception as e:\n
except Exception as e:\n
print(e)\n
print(repr(e))\n
finally:\n
template_tool.manage_delObjects(ids=[installed_bt_for_diff.getId()])\n
template_tool.manage_delObjects(ids=[installed_bt_for_diff.getId()])\n
\n
\n
#return "
<pre>
" + printed.replace("
&
", "
&
").replace("
<
", "
<
").replace(">", "
>
").replace("\\"", "
"
") + "
</pre>
"\n
return printed\n
return printed #.split("\\n")\n
]]>
</string>
</value>
]]>
</string>
</value>
...
@@ -130,7 +124,7 @@ return printed #.split("\\n")\n
...
@@ -130,7 +124,7 @@ return printed #.split("\\n")\n
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
BusinessTemplate_get
DiffWithZODBAsText
</string>
</value>
<value>
<string>
BusinessTemplate_get
PrintableDiffWithZODB
</string>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
...
...
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getPrintableModificationListFromZODB.xml
0 → 100644
View file @
c283984e
<?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 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
if context.getBuildingState() != "built":\n
return "AssertionError(\\"%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 = installed_bt_for_diff.preinstall(check_dependencies=0, compare_to=business_template)\n
keys = modified_object_list.keys()\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(repr(e))\n
return printed\n
\n
try:\n
installed_bt_for_diff.setId("installed_bt_for_diff")\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
except ConflictError:\n
raise\n
except Exception as e:\n
print(repr(e))\n
template_tool.manage_delObjects(ids=[installed_bt_for_diff.getId()])\n
\n
return printed\n
]]>
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
BusinessTemplate_getPrintableModificationListFromZODB
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Folder_resolvePath.xml
0 → 100644
View file @
c283984e
<?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[
"""Usage example:\n
\n
- in a url ``<your erp5 url>
/portal_skins/Folder_resolvePath?path=**``\n
- in a script ``context.Folder_resolvePath("**")``\n
- for a business template path list ``portal.Folder_resolvePath(bt.getTemplatePathList())``\n
\n
Arguments:\n
\n
- ``path`` can be a string or a list (if ``path_list`` is not defined).\n
- ``path_list`` must be a list (if ``path`` is not defined).\n
- ``traverse`` if True, return object list instead of path list.\n
- ``globbing`` if False, handle "*" and "**" as normal id.\n
"""\n
if path is None:\n
if path_list is None:\n
raise TypeError("`path` or `path_list` argument should be defined")\n
elif isinstance(path, (list, tuple)):\n
path_list = path\n
else:\n
path_list = [path]\n
\n
context_is_portal = context.getPortalObject() == context\n
contextTraverse = context.restrictedTraverse\n
\n
resolved_list = []\n
append = resolved_list.append\n
\n
if globbing:\n
for path in path_list:\n
if path == "*" or (context_is_portal and path == "**"): # acts like _resolvePath in Products.ERP5.Document.BusinessTemplate.PathTemplateItem\n
for sub_path, sub_obj in context.ZopeFind(context, search_sub=0):\n
if traverse:\n
append(sub_obj)\n
else:\n
append(sub_path)\n
elif path == "**":\n
for sub_path, sub_obj in context.ZopeFind(context, search_sub=1):\n
if traverse:\n
append(sub_obj)\n
else:\n
append(sub_path)\n
elif path.endswith("/**"):\n
parent_path = path[:-3]\n
obj = contextTraverse(parent_path)\n
for sub_path, sub_obj in obj.ZopeFind(obj, search_sub=1):\n
if traverse:\n
append(sub_obj)\n
else:\n
append(parent_path + "/" + sub_path)\n
elif path.endswith("/*"):\n
parent_path = path[:-2]\n
obj = contextTraverse(parent_path)\n
for sub_path, sub_obj in obj.ZopeFind(obj, search_sub=0):\n
if traverse:\n
append(sub_obj)\n
else:\n
append(parent_path + "/" + sub_path)\n
else:\n
if traverse:\n
append(contextTraverse(path))\n
else:\n
append(path)\n
else:\n
for path in path_list:\n
if traverse:\n
append(contextTraverse(path))\n
else:\n
append(path)\n
return resolved_list\n
]]>
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
path=None, path_list=None, traverse=False, globbing=True
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Folder_resolvePath
</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