Commit da741f7e authored by Yoshinori Okuji's avatar Yoshinori Okuji

2007-11-02 yo

* Simplify  and cache-free Form_getGroupTitleAndId.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17381 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dbcddc0a
...@@ -91,38 +91,26 @@ ...@@ -91,38 +91,26 @@
, \'left webcontent (The Fantastic Group (and (funky) lisp-like parenthesis)) extra\'\n , \'left webcontent (The Fantastic Group (and (funky) lisp-like parenthesis)) extra\'\n
)\n )\n
"""\n """\n
from Products.ERP5Type.Cache import CachingMethod\n
\n
form=context\n form=context\n
\n \n
def getFormGroupTitleAndId():\n def getFormGroupTitleAndId():\n
res = []\n res = []\n
append = res.append\n
for original_group_id in form.get_groups(include_empty=0):\n for original_group_id in form.get_groups(include_empty=0):\n
# Separate the group id and the group title using parenthesis as marker from the original form group id\n group_id = original_group_id\n
o_gid_list = original_group_id.strip().split(\'(\')\n try:\n
# Get the first part of the group id (which is the part before the first opened parenthesis)\n group_id_head, group_id_rest = group_id.split(\'(\', 1)\n
group_id = o_gid_list[0]\n group_title, group_id_tail = group_id_rest.rsplit(\')\', 1)\n
# Get the end of the list (which is the part just after the first opened parenthesis)\n group_id = group_id_head + group_id_tail\n
group_title_list = \'(\'.join(o_gid_list[1:]).split(\')\')\n if not group_title:\n
# Get the last part of the group id (the part which stand after the last closing parenthesis)\n group_title = None\n
group_id += group_title_list[-1]\n except ValueError:\n
# Normalize the group id (suppress unecessary multiple-space)\n # When group_id does not have parentheses.\n
group_id_list = []\n
for group_word in group_id.split(\' \'):\n
if len(group_word):\n
group_id_list.append(group_word)\n
group_id = \' \'.join(group_id_list)\n
# Generate the group title\n
group_title = \')\'.join(group_title_list[:-1]).strip()\n
# Return the group id if no title found\n
if len(group_title) == 0:\n
group_title = None\n group_title = None\n
res.append({\'gid\': group_id, \'gtitle\': group_title, \'goid\': original_group_id})\n group_id = \' \'.join((w for w in group_id.split(\' \') if w))\n
append({\'gid\': group_id, \'gtitle\': group_title, \'goid\': original_group_id})\n
return res\n return res\n
\n \n
getFormGroupTitleAndId = CachingMethod(getFormGroupTitleAndId,\n
("ERP5Site_getFormGroupTitleAndId", form.id, form.get_groups(include_empty=0)),\n
cache_factory=\'erp5_ui_long\')\n
return getFormGroupTitleAndId()\n return getFormGroupTitleAndId()\n
</string> </value> </string> </value>
</item> </item>
...@@ -172,12 +160,9 @@ return getFormGroupTitleAndId()\n ...@@ -172,12 +160,9 @@ return getFormGroupTitleAndId()\n
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>context</string> <string>context</string>
<string>form</string> <string>form</string>
<string>getFormGroupTitleAndId</string> <string>getFormGroupTitleAndId</string>
<string>_getattr_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
425 426
\ 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