Commit 6e837052 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

* Index portal_type in translation table to avoid unexpected verbose results...

* Index portal_type in translation table to avoid unexpected verbose results of translated state search.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36306 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7ef756fc
......@@ -53,32 +53,42 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Document import newTempBase\n
from Products.ERP5Type.Utils import getMessageIdWithContext\n
<value> <string>from Products.ERP5Type.Utils import getMessageIdWithContext\n
\n
supported_languages = context.Localizer.get_supported_languages()\n
translated_keys = {} # This dict prevents entering the same key twice\n
\n
context.portal_catalog.deleteTranslationList(sql_catalog_id=sql_catalog_id)\n
sql_catalog = context.portal_catalog.getSQLCatalog(sql_catalog_id)\n
sql_catalog.z0_drop_translation()\n
sql_catalog.z_create_translation()\n
\n
i = 0\n
z_catalog_translation_list = sql_catalog.z_catalog_translation_list\n
def catalog_translation_list(object_list):\n
parameter_dict = {}\n
for i in object_list:\n
for property in (\'language\', \'message_context\', \'portal_type\',\n
\'original_message\', \'translated_message\'):\n
parameter_dict.setdefault(property, []).append(i[property])\n
z_catalog_translation_list(**parameter_dict)\n
\n
# Translate every workflow state in the context of the state variable\n
for wf in context.portal_workflow.objectValues():\n
object_list = []\n
object_list = []\n
portal_workflow = context.portal_workflow\n
for wf_id, portal_type_list in portal_workflow.getChainDict().items():\n
wf = getattr(portal_workflow, wf_id, None)\n
if wf is None:\n
continue\n
state_var = wf.variables.getStateVar()\n
if wf.states:\n
for state_id, state in wf.states.items():\n
for lang in supported_languages:\n
key = (lang, state_var, state_id)\n
for portal_type in portal_type_list:\n
key = (lang, portal_type, state_var, state_id)\n
if not translated_keys.has_key(key):\n
translated_message = context.Localizer.erp5_ui.gettext(state_id, lang=lang).encode(\'utf-8\')\n
translated_keys[key] = None # mark as translated\n
obj = newTempBase(context, \'temp_translation_%d\' % i,\n
language=lang, message_context=state_var, original_message=state_id,\n
translated_message = context.Localizer.erp5_ui.gettext(state_id, lang=lang).encode(\'utf-8\'))\n
obj.setUid(\'temp_%d\' % i)\n
i += 1\n
object_list.append(obj)\n
object_list.append(dict(language=lang, message_context=state_var, portal_type=portal_type, original_message=state_id,\n
translated_message=translated_message))\n
\n
# translate state title as well\n
if state.title != \'\' :\n
......@@ -88,38 +98,27 @@ for wf in context.portal_workflow.objectValues():\n
if translated_message == \'\':\n
msg_id = state.title\n
translated_message = context.Localizer.erp5_ui.gettext(state.title.decode(\'utf-8\'), lang=lang).encode(\'utf-8\')\n
key = (lang, state_var_title, state_id, msg_id)\n
key = (lang, portal_type, state_var_title, state_id, msg_id)\n
if not translated_keys.has_key(key):\n
translated_keys[key] = None # mark as translated\n
obj = newTempBase(context, \'temp_translation_%d\' % i,\n
language=lang, message_context=state_var_title,\n
original_message = state_id, translated_message = translated_message )\n
obj.setUid(\'temp_%d\' % i)\n
i += 1\n
object_list.append(obj)\n
\n
if object_list:\n
context.portal_catalog.catalogTranslationList(object_list, sql_catalog_id=sql_catalog_id)\n
object_list.append(dict(language=lang, message_context=state_var_title, portal_type=portal_type, original_message=state_id,\n
translated_message=translated_message))\n
if object_list:\n
catalog_translation_list(object_list)\n
\n
# Translate every portal type in the context of the portal type\n
object_list = []\n
for ptype in context.portal_types.objectValues():\n
title = ptype.title\n
if not title: title = ptype.id\n
object_list = []\n
portal_type = ptype.title\n
if not portal_type: portal_type = ptype.id\n
for lang in supported_languages:\n
key = (lang, \'portal_type\', title)\n
key = (lang, \'portal_type\', portal_type)\n
if not translated_keys.has_key(key):\n
translated_keys[key] = None # mark as translated\n
obj = newTempBase(context, \'temp_translation_%d\' % i,\n
language=lang, message_context="portal_type",\n
original_message = title,\n
translated_message = context.Localizer.erp5_ui.gettext(title, lang=lang).encode(\'utf-8\'))\n
obj.setUid(\'temp_%d\' % i)\n
i += 1\n
object_list.append(obj)\n
\n
if object_list:\n
context.portal_catalog.catalogTranslationList(object_list, sql_catalog_id=sql_catalog_id)\n
object_list.append(dict(language=lang, message_context=\'portal_type\', portal_type=portal_type, original_message=portal_type,\n
translated_message=context.Localizer.erp5_ui.gettext(portal_type, lang=lang).encode(\'utf-8\')))\n
if object_list:\n
catalog_translation_list(object_list)\n
\n
print \'Done\'\n
return printed\n
......@@ -162,32 +161,35 @@ return printed\n
<string>sql_catalog_id</string>
<string>_print_</string>
<string>_print</string>
<string>Products.ERP5Type.Document</string>
<string>newTempBase</string>
<string>Products.ERP5Type.Utils</string>
<string>getMessageIdWithContext</string>
<string>_getattr_</string>
<string>context</string>
<string>supported_languages</string>
<string>translated_keys</string>
<string>i</string>
<string>sql_catalog</string>
<string>z_catalog_translation_list</string>
<string>catalog_translation_list</string>
<string>object_list</string>
<string>portal_workflow</string>
<string>_getiter_</string>
<string>wf_id</string>
<string>portal_type_list</string>
<string>getattr</string>
<string>None</string>
<string>wf</string>
<string>object_list</string>
<string>state_var</string>
<string>state_id</string>
<string>state</string>
<string>lang</string>
<string>portal_type</string>
<string>key</string>
<string>None</string>
<string>translated_message</string>
<string>_write_</string>
<string>obj</string>
<string>_inplacevar_</string>
<string>dict</string>
<string>state_var_title</string>
<string>msg_id</string>
<string>translated_message</string>
<string>ptype</string>
<string>title</string>
</tuple>
</value>
</item>
......
2010-06-14 Kazuhiko
* Index portal_type in translation table to avoid unexpected verbose results of translated state search.
2010-06-09 yusei
* Fix a typo in CategoryTool_getPreferredPredicateCategoryParentUidItemList.
......
1612
\ No newline at end of file
1613
\ No newline at end of file
......@@ -36,6 +36,12 @@
</object>
</value>
</item>
<item>
<key> <string>_col</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
......
......@@ -41,6 +41,12 @@
<dictionary/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>translated_message</string> </key>
<value>
......@@ -56,6 +62,7 @@
<list>
<string>language</string>
<string>message_context</string>
<string>portal_type</string>
<string>original_message</string>
<string>translated_message</string>
</list>
......@@ -76,6 +83,7 @@
<key> <string>arguments_src</string> </key>
<value> <string>language\r\n
message_context\r\n
portal_type\r\n
original_message\r\n
translated_message</string> </value>
</item>
......@@ -122,6 +130,7 @@ INSERT INTO translation VALUES \n
(\n
<dtml-sqlvar expr="language[loop_item]" type="string">,\n
<dtml-sqlvar expr="message_context[loop_item]" type="string">,\n
<dtml-sqlvar expr="portal_type[loop_item]" type="string">,\n
<dtml-sqlvar expr="original_message[loop_item]" type="string">,\n
<dtml-sqlvar expr="translated_message[loop_item]" type="string">\n
)\n
......@@ -172,6 +181,7 @@ INSERT INTO translation VALUES \n
(\n
<dtml-sqlvar expr="language[loop_item]" type="string">,\n
<dtml-sqlvar expr="message_context[loop_item]" type="string">,\n
<dtml-sqlvar expr="portal_type[loop_item]" type="string">,\n
<dtml-sqlvar expr="original_message[loop_item]" type="string">,\n
<dtml-sqlvar expr="translated_message[loop_item]" type="string">\n
)\n
......
......@@ -36,6 +36,12 @@
</object>
</value>
</item>
<item>
<key> <string>_col</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
......@@ -85,10 +91,12 @@
<value> <string>CREATE TABLE translation (\n
language VARCHAR(255),\n
message_context VARCHAR(50),\n
portal_type VARCHAR(255),\n
original_message VARCHAR(255),\n
translated_message VARCHAR(255),\n
KEY `message` (`translated_message`),\n
KEY `original_message` (`original_message`)\n
KEY `original_message` (`original_message`),\n
KEY `portal_type` (`portal_type`)\n
) TYPE=InnoDB;\n
</string> </value>
</item>
......@@ -129,10 +137,12 @@
<value> <string>CREATE TABLE translation (\n
language VARCHAR(255),\n
message_context VARCHAR(50),\n
portal_type VARCHAR(255),\n
original_message VARCHAR(255),\n
translated_message VARCHAR(255),\n
KEY `message` (`translated_message`),\n
KEY `original_message` (`original_message`)\n
KEY `original_message` (`original_message`),\n
KEY `portal_type` (`portal_type`)\n
) TYPE=InnoDB;\n
</string> </value>
</item>
......
......@@ -95,6 +95,7 @@
<dtml-var table_0>.original_message = catalog.causality_state\n
AND <dtml-var table_0>.message_context = "causality_state"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......@@ -137,6 +138,7 @@
<dtml-var table_0>.original_message = catalog.causality_state\n
AND <dtml-var table_0>.message_context = "causality_state"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......
......@@ -95,6 +95,7 @@
<dtml-var table_0>.original_message = catalog.causality_state\n
AND <dtml-var table_0>.message_context = "causality_state_title"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......@@ -137,6 +138,7 @@
<dtml-var table_0>.original_message = catalog.causality_state\n
AND <dtml-var table_0>.message_context = "causality_state_title"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......
......@@ -95,6 +95,7 @@
<dtml-var table_0>.original_message = catalog.opportunity_state\n
AND <dtml-var table_0>.message_context = "opportunity_state"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">\n
......@@ -138,6 +139,7 @@
<dtml-var table_0>.original_message = catalog.opportunity_state\n
AND <dtml-var table_0>.message_context = "opportunity_state"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">\n
......
......@@ -95,6 +95,7 @@
<dtml-var table_0>.original_message = catalog.opportunity_state\n
AND <dtml-var table_0>.message_context = "opportunity_state_title"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">\n
......@@ -138,6 +139,7 @@
<dtml-var table_0>.original_message = catalog.opportunity_state\n
AND <dtml-var table_0>.message_context = "opportunity_state_title"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">\n
......
......@@ -95,6 +95,7 @@
<dtml-var table_0>.original_message = catalog.simulation_state\n
AND <dtml-var table_0>.message_context = "simulation_state"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......@@ -137,6 +138,7 @@
<dtml-var table_0>.original_message = catalog.simulation_state\n
AND <dtml-var table_0>.message_context = "simulation_state"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......
......@@ -95,7 +95,9 @@
<dtml-var table_0>.original_message = catalog.simulation_state\n
AND <dtml-var table_0>.message_context = "simulation_state_title"\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">\n
]]></string> </value>
</item>
......@@ -137,7 +139,9 @@
<dtml-var table_0>.original_message = catalog.simulation_state\n
AND <dtml-var table_0>.message_context = "simulation_state_title"\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">\n
]]></string> </value>
</item>
......
......@@ -95,6 +95,7 @@
<dtml-var table_0>.original_message = catalog.validation_state\n
AND <dtml-var table_0>.message_context = "validation_state"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......@@ -137,6 +138,7 @@
<dtml-var table_0>.original_message = catalog.validation_state\n
AND <dtml-var table_0>.message_context = "validation_state"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......
......@@ -95,6 +95,7 @@
<dtml-var table_0>.original_message = catalog.validation_state\n
AND <dtml-var table_0>.message_context = "validation_state_title"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......@@ -137,6 +138,7 @@
<dtml-var table_0>.original_message = catalog.validation_state\n
AND <dtml-var table_0>.message_context = "validation_state_title"\n
AND <dtml-var table_0>.portal_type = catalog.portal_type\n
AND <dtml-var table_0>.language = <dtml-sqlvar "Localizer.get_selected_language()" type="string">
]]></string> </value>
......
2010-06-08 Kazuhiko
* Add portal_type column in translation table and use it in several related keys to avoid unexpected verbose results of translated state search.
2010-06-08 yusei
* Add predicate category related keys.
* Update predicate category indexing method to support "no-left-join" version of predicate search.
......
......@@ -799,6 +799,17 @@ WorkflowTool.getWorkflowChainDict = WorkflowTool_getWorkflowChainDict
WorkflowTool._reindexWorkflowVariables = lambda self, ob: \
hasattr(aq_base(ob), 'reindexObjectSecurity') and ob.reindexObjectSecurity()
def WorkflowTool_getChainDict(self):
"""Test if the given transition exist from the current state.
"""
chain_dict = {}
for portal_type, wf_id_list in self._chains_by_type.iteritems():
for wf_id in wf_id_list:
chain_dict.setdefault(wf_id, []).append(portal_type)
return chain_dict
WorkflowTool.getChainDict = WorkflowTool_getChainDict
# Backward compatibility, as WorkflowMethod has been removed in CMFCore 2.2
from MethodObject import Method
class WorkflowMethod( Method ):
......
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