Commit 747db007 authored by Łukasz Nowak's avatar Łukasz Nowak

- extended script to support case of containers with same type as children, updated docstring

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22186 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 206dcf69
...@@ -65,19 +65,38 @@ ...@@ -65,19 +65,38 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""Initialise int_index and reference of object"""\n <value> <string encoding="cdata"><![CDATA[
"""Initialise int_index and reference of object\n
It will set reference to int_index, as string.\n
In case if container is same type is its children, reference is generated as\n
<container_reference>.<children_reference>:\n
1\n
1.1\n
1.2\n
1.2.1\n
1.2.2\n
1.3\n
1.3.1\n
"""\n
\n \n
parent = context.getParentValue()\n parent = context.getParentValue()\n
portal_type = context.getPortalType()\n portal_type = context.getPortalType()\n
\n \n
index = len(parent.contentValues(filter={"portal_type": portal_type}))\n index = len(parent.contentValues(filter={"portal_type": portal_type}))\n
reference = str(index)\n \n
if parent.getPortalType() == portal_type:\n
reference = "%s.%s" % (parent.getReference(), index)\n
else:\n
reference = str(index)\n
\n \n
context.edit(\n context.edit(\n
int_index = index,\n int_index = index,\n
reference = reference\n reference = reference\n
)\n )\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -133,8 +152,8 @@ context.edit(\n ...@@ -133,8 +152,8 @@ context.edit(\n
<string>portal_type</string> <string>portal_type</string>
<string>len</string> <string>len</string>
<string>index</string> <string>index</string>
<string>str</string>
<string>reference</string> <string>reference</string>
<string>str</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
361 363
\ No newline at end of file \ No newline at end of file
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