ods_style: use a script to properly get all editable fields
<?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>request = container.REQUEST\n | |||
\n | |||
# XXX this is a restricted environment available reimplementation of ListboxRenderer.getEditableField\n | |||
editable_columns = set(context.get_value(\'columns\', REQUEST=request)\n | |||
+ context.get_value(\'all_columns\', REQUEST=request))\n | |||
\n | |||
editable_fields = {}\n | |||
\n | |||
def getEditableField(alias):\n | |||
"""Get an editable field for column, using column alias.\n | |||
Return None if a field for this column does not exist.\n | |||
"""\n | |||
field = context\n | |||
original_field_id = field.id\n | |||
while True:\n | |||
for field_id in {original_field_id, field.id}:\n | |||
if field.aq_parent.has_field("%s_%s" % (field_id, alias), include_disabled=1):\n | |||
return field.aq_parent.get_field("%s_%s" % (field_id, alias),\n | |||
include_disabled=1)\n | |||
if field.meta_type != \'ProxyField\':\n | |||
return None\n | |||
# if we are rendering a proxy field, also look for editable fields from\n | |||
# the template field\'s form. This editable field can be prefixed either\n | |||
# by the template field listbox id or by the proxy field listbox id.\n | |||
field = field.getTemplateField().aq_inner\n | |||
\n | |||
for column, _ in editable_columns:\n | |||
field = getEditableField(column)\n | |||
|
|||
if field is not None:\n | |||
editable_fields[column] = field\n | |||
\n | |||
return editable_fields\n | |||
</string> </value> | |||
</item> | |||
<item> | |||
<key> <string>_params</string> </key> | |||
<value> <string></string> </value> | |||
</item> | |||
<item> | |||
<key> <string>id</string> </key> | |||
<value> <string>Listbox_getEditableFieldDict</string> </value> | |||
</item> | |||
</dictionary> | |||
</pickle> | |||
</record> | |||
</ZopeData> |