Commit 2fce628b authored by Vincent Pelletier's avatar Vincent Pelletier

Make Base_getFieldDescription design more object-oriented-ish.

Rename Base_getFieldDescription into Field_getDescription.
Update callers.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15502 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 78b6bb2b
...@@ -70,26 +70,36 @@ ...@@ -70,26 +70,36 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Cache import CachingMethod\n <value> <string>from Products.ERP5Type.Cache import CachingMethod\n
\n \n
field = context\n
field_id = field.getId()\n field_id = field.getId()\n
form = field.aq_parent\n
form_id = form.getId()\n
document = form.aq_parent\n
if getattr(document, \'getPortalType\', None) is None:\n
document = None\n
\n \n
def getFieldDescription():\n def getFieldDescription(field_id):\n
desc = field.get_value(\'description\')\n desc = field.get_value(\'description\')\n
if desc in (\'\', None):\n if desc in (\'\', None):\n
id = field_id.split(\'_\', 1)\n split_id = field_id.split(\'_\', 1)\n
if id[0] == \'my\':\n if split_id[0] == \'my\':\n
if document is None:\n
desc = \'Dummy field description for %s\' % (field_id, )\n
else:\n
try:\n try:\n
properties = context.propertyMap()\n properties = document.propertyMap()\n
except AttributeError: # If context has no propertyMap, give up\n except AttributeError: # If context has no propertyMap, give up\n
properties = []\n properties = []\n
for property in properties:\n for property in properties:\n
if id[1] == property[\'id\']:\n if split_id[1] == property[\'id\']:\n
return property.get(\'description\', \'\')\n desc = property.get(\'description\', \'\')\n
break\n
return desc\n return desc\n
\n \n
getFieldDescription = CachingMethod(getFieldDescription, (\'getFieldDescription\', form_id, field_id), \\\n if document is not None:\n
getFieldDescription = CachingMethod(getFieldDescription, (\'getFieldDescription\', form_id), \\\n
cache_factory=\'erp5_ui_long\')\n cache_factory=\'erp5_ui_long\')\n
\n return getFieldDescription(field_id)\n
return getFieldDescription()\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -112,7 +122,7 @@ return getFieldDescription()\n ...@@ -112,7 +122,7 @@ return getFieldDescription()\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>form_id, field</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -132,18 +142,23 @@ return getFieldDescription()\n ...@@ -132,18 +142,23 @@ return getFieldDescription()\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>form_id</string>
<string>field</string>
<string>Products.ERP5Type.Cache</string> <string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string> <string>CachingMethod</string>
<string>context</string>
<string>field</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>field_id</string> <string>field_id</string>
<string>form</string>
<string>form_id</string>
<string>document</string>
<string>getattr</string>
<string>None</string>
<string>getFieldDescription</string> <string>getFieldDescription</string>
</tuple> </tuple>
</value> </value>
...@@ -161,7 +176,7 @@ return getFieldDescription()\n ...@@ -161,7 +176,7 @@ return getFieldDescription()\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Base_getFieldDescription</string> </value> <value> <string>Field_getDescription</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
...@@ -85,7 +85,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n ...@@ -85,7 +85,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
field_errors python: request.get(\'field_errors\', {});\n field_errors python: request.get(\'field_errors\', {});\n
field_has_error python: field_errors.has_key(field_id);\n field_has_error python: field_errors.has_key(field_id);\n
global form_id form_id | python: form.id;\n global form_id form_id | python: form.id;\n
field_description python: here.Base_getFieldDescription(form_id=form_id, field=field);\n field_description field/Field_getDescription;\n
is_web_mode is_web_mode | nothing">\n is_web_mode is_web_mode | nothing">\n
<div tal:define="html_render python: field.render_htmlgrid(value, request)"\n <div tal:define="html_render python: field.render_htmlgrid(value, request)"\n
tal:attributes="title field_description;\n tal:attributes="title field_description;\n
......
...@@ -150,7 +150,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n ...@@ -150,7 +150,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
<tal:block tal:condition="preferred_html_style_developper_mode">\n <tal:block tal:condition="preferred_html_style_developper_mode">\n
<tal:block metal:use-macro="developper_shortcut_render/macros/field_developper"/>\n <tal:block metal:use-macro="developper_shortcut_render/macros/field_developper"/>\n
</tal:block>\n </tal:block>\n
<tal:block tal:define="field_description python: here.Base_getFieldDescription(form_id=form.id, field=field)"\n <tal:block tal:define="field_description field/Field_getDescription"\n
tal:condition="preferred_html_style_translator_mode">\n tal:condition="preferred_html_style_translator_mode">\n
<tal:block metal:use-macro="developper_shortcut_render/macros/field_translator"/>\n <tal:block metal:use-macro="developper_shortcut_render/macros/field_translator"/>\n
</tal:block>\n </tal:block>\n
......
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