Commit 9641c1ea authored by Ivan Tyagov's avatar Ivan Tyagov

Add generic code to check if a document is convertible in one place : Base_isConvertible.

Make sure convert is not called in case resource is not convertible.
parent 8af6f860
......@@ -62,10 +62,7 @@ if address not in MARKER and port not in MARKER:\n
for index_uid in range(len(uid)):\n
document_relative_url = getRelativeUrl[index_uid]\n
document = portal.restrictedTraverse(document_relative_url)\n
# XXX: we do check if "data" methods exists on pretending to be Document portal types\n
# we need a way to do this by introspection\n
if ((getattr(document, "getData", None) is not None and document.getData() not in MARKER) or \\\n
(getattr(document, "getBaseData", None) is not None and document.getBaseData() not in MARKER)):\n
if document.Base_isConvertible():\n
document.activate(priority=4, tag="conversion").Base_callPreConvert()\n
</string> </value>
</item>
......
......@@ -56,11 +56,8 @@
"""\n
portal = context.getPortalObject()\n
\n
portal_type = context.getPortalType()\n
allowed_portal_type_list = portal.getPortalDocumentTypeList() + portal.getPortalEmbeddedDocumentTypeList()\n
\n
if portal_type not in allowed_portal_type_list:\n
# no need to convert any non DMS types\n
if not context.Base_isConvertible():\n
# no need to convert any non convertible types\n
return\n
\n
if kw=={}:\n
......
<?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>"""\n
Return true or false based on if document is convertible or not.\n
"""\n
MARKER = (None, \'\',)\n
portal = context.getPortalObject()\n
\n
portal_type = context.getPortalType()\n
allowed_portal_type_list = portal.getPortalDocumentTypeList() + portal.getPortalEmbeddedDocumentTypeList()\n
\n
if portal_type not in allowed_portal_type_list:\n
return False\n
\n
# XXX: we do check if "data" methods exists on pretending to be Document portal types\n
# we need a way to do this by introspection\n
return (getattr(context, "getData", None) is not None and context.getData() not in MARKER) or \\\n
(getattr(context, "getBaseData", None) is not None and context.getBaseData() not in MARKER)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_isConvertible</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
20
\ No newline at end of file
21
\ 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