Commit 54416b5c authored by Ivan Tyagov's avatar Ivan Tyagov

Add script that is able to determine (based on content_type) list of possible...

Add script that is able to determine (based on content_type) list of possible convert to target format lists.
Script is used (and uses) for portal types that do rely on portal_transforms & mimetypes_registry.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36808 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 33835a3c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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>"""\n
Returns a list of acceptable formats for conversion\n
in the form of tuples (for listfield in ERP5Form)\n
"""\n
from Products.ERP5Type.Cache import CachingMethod\n
\n
content_type = context.getContentType()\n
\n
def getTargetFormatItemList(content_type):\n
format_list = []\n
output_content_type_list = []\n
for obj in context.portal_transforms.objectValues():\n
for input in obj.inputs:\n
if input==content_type and \\\n
obj.output not in output_content_type_list and\\\n
obj.output!=content_type:\n
output_content_type_list.append(obj.output)\n
\n
for output_content_type in output_content_type_list:\n
mimetypes_registry_extension_list = context.mimetypes_registry.lookup(output_content_type)\n
for mimetypes_registry_extension in mimetypes_registry_extension_list:\n
title = mimetypes_registry_extension.name()\n
try:\n
format = mimetypes_registry_extension.extensions[0]\n
except IndexError:\n
format = None\n
if format is not None and format not in format_list:\n
format_list.append((title, format,))\n
return format_list\n
\n
getTargetFormatItemList = CachingMethod(getTargetFormatItemList,\n
id=\'Base_getTargetFormatItemList\',\n
cache_factory=\'erp5_ui_long\')\n
\n
return getTargetFormatItemList(content_type)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>_getattr_</string>
<string>context</string>
<string>content_type</string>
<string>getTargetFormatItemList</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getTargetFormatItemList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
1155
\ No newline at end of file
1156
\ 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