Commit 13f13eb8 authored by Ivan Tyagov's avatar Ivan Tyagov

Use ZSQLCatalog to filter convertable documents.

Use getTypeBasedMethod and unify handlers.
parent a0ee2634
No related merge requests found
...@@ -2,4 +2,13 @@ ...@@ -2,4 +2,13 @@
<item key="sql_catalog_object_list" type="int"> <item key="sql_catalog_object_list" type="int">
<value>1</value> <value>1</value>
</item> </item>
<item key="_is_filtered_archive" type="int">
<value>1</value>
</item>
<item key="_filter_expression_archive" type="str">
<value>python: context.isDocument()</value>
</item>
<item key="_filter_expression_cache_key_archive" type="tuple">
<value>portal_type</value>
</item>
</catalog_method> </catalog_method>
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string>portal = context.getPortalObject()\n
portal_id = portal.getId()\n
MARKER = (None, \'\',)\n MARKER = (None, \'\',)\n
\n \n
address = portal.portal_preferences.getPreferredOoodocServerAddress()\n address = portal.portal_preferences.getPreferredOoodocServerAddress()\n
...@@ -61,18 +60,16 @@ port = portal.portal_preferences.getPreferredOoodocServerPortNumber()\n ...@@ -61,18 +60,16 @@ port = portal.portal_preferences.getPreferredOoodocServerPortNumber()\n
# is installed BEFORE the real cloudoo is setup in preferences.\n # is installed BEFORE the real cloudoo is setup in preferences.\n
if address not in MARKER and port not in MARKER:\n if address not in MARKER and port not in MARKER:\n
for index_uid in range(len(uid)):\n for index_uid in range(len(uid)):\n
document_relative_url = getPath[index_uid].replace("/%s/" %portal_id, "")\n document_relative_url = getRelativeUrl[index_uid]\n
document = portal.restrictedTraverse(document_relative_url)\n document = portal.restrictedTraverse(document_relative_url)\n
if getattr(document, "convert", None) is not None and \\\n if (document.getData() not in MARKER or document.getBaseData() not in MARKER):\n
getattr(document, "getData", None) is not None and \\\n
(document.getData() not in MARKER or document.getBaseData() not in MARKER):\n
#context.log("preconvert %s" %document.getRelativeUrl())\n #context.log("preconvert %s" %document.getRelativeUrl())\n
document.activate(serialize_tag="conversion").Base_preConvert()\n document.activate(serialize_tag="conversion").Base_callPreConvert()\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>uid, getPath</string> </value> <value> <string>uid, getRelativeUrl</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -51,32 +51,30 @@ ...@@ -51,32 +51,30 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Do actual conversion of any Document type.\n Pre convert to know good defaults.\n
Use type based methods to allow finer granularity (for example in case of PDF we support many frames inside a document).\n
"""\n """\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
\n \n
format_kw = {\'format\': format,\n portal_type = context.getPortalType()\n
\'quality\': quality}\n format = portal.portal_preferences.getPreferredImageFormat()\n
for display in display_list:\n quality = portal.portal_preferences.getPreferredImageQuality()\n
format_kw[\'display\'] = display\n preferred_image_size = portal.portal_preferences.getPreferredImageSize()\n
context.convert(**format_kw)\n \n
# thumbnail is required always\n
display_list = ["thumbnail"]\n
method = context.getTypeBasedMethod(\'preConvert\')\n
context.log(method)\n
return method(**dict(format=format, quality=quality, display_list = display_list))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>format, quality, display_list</string> </value> <value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Document_preConvert</string> </value> <value> <string>Base_callPreConvert</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -51,26 +51,28 @@ ...@@ -51,26 +51,28 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Pre convert to know good defaults.\n Do actual conversion of any Base type.\n
Use type based methods to allow finer granularity (for example in case of PDF we support many frames inside a document).\n
"""\n """\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
\n \n
portal_type = context.getPortalType()\n format_kw = {\'format\': format,\n
format = portal.portal_preferences.getPreferredImageFormat()\n \'quality\': quality}\n
quality = portal.portal_preferences.getPreferredImageQuality()\n for display in display_list:\n
preferred_image_size = portal.portal_preferences.getPreferredImageSize()\n format_kw[\'display\'] = display\n
\n context.convert(**format_kw)\n
# thumbnail is required always\n
display_list = ["thumbnail"]\n
method_id = \'%s_preConvert\' %portal_type.replace(\' \', \'\')\n
method = getattr(context, method_id, context.Document_preConvert)\n
return method(**dict(format=format, quality=quality, display_list = display_list))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>format, quality, display_list</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
It will do that recursively in entire ERP5 instance.\n It will do that recursively in entire ERP5 instance.\n
\n \n
"""\n """\n
context.ERP5Site_checkDataWithScript("Base_preConvert", \n context.ERP5Site_checkDataWithScript("Base_callPreConvert", \n
tag="pre_convert",\n tag="pre_convert",\n
packet=2,\n packet=2,\n
id_list=["document_module", "image_module"])\n id_list=["document_module", "image_module"])\n
......
...@@ -51,10 +51,9 @@ ...@@ -51,10 +51,9 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Do actual conversion of Spreadsheet type.\n Do actual conversion of any Image type.\n
"""\n """\n
context.convert(**{\'format\': \'html\'})\n context.Base_preConvert(format, quality, display_list)\n
context.Document_preConvert(format, quality, display_list)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -71,7 +70,7 @@ context.Document_preConvert(format, quality, display_list)\n ...@@ -71,7 +70,7 @@ context.Document_preConvert(format, quality, display_list)\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Text_preConvert</string> </value> <value> <string>Image_preConvert</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
Do actual conversion of Spreadsheet type.\n Do actual conversion of Spreadsheet type.\n
"""\n """\n
context.convert(**{\'format\': \'html\'})\n context.convert(**{\'format\': \'html\'})\n
context.Document_preConvert(format, quality, display_list)\n context.Base_preConvert(format, quality, display_list)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -71,7 +71,7 @@ context.Document_preConvert(format, quality, display_list)\n ...@@ -71,7 +71,7 @@ context.Document_preConvert(format, quality, display_list)\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Spreadsheet_preConvert</string> </value> <value> <string>OOoDocument_preConvert</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -51,10 +51,9 @@ ...@@ -51,10 +51,9 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Do actual conversion of Spreadsheet type.\n Do actual conversion of any Image type.\n
"""\n """\n
context.convert(**{\'format\': \'html\'})\n context.Base_preConvert(format, quality, display_list)\n
context.Document_preConvert(format, quality, display_list)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -71,7 +70,7 @@ context.Document_preConvert(format, quality, display_list)\n ...@@ -71,7 +70,7 @@ context.Document_preConvert(format, quality, display_list)\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Drawing_preConvert</string> </value> <value> <string>TextDocument_preConvert</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
5 6
\ 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