Commit cfa6c8f5 authored by Yusei Tahara's avatar Yusei Tahara

2008-2-14 Yusei

* Improve wiki successor/predecessor.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19320 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 57acea18
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<string>Products.PythonScripts.PythonScript</string> <tuple/>
<string>PythonScript</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -75,30 +72,11 @@ we can return raw set, the class will get objects and make the records unique\n ...@@ -75,30 +72,11 @@ we can return raw set, the class will get objects and make the records unique\n
and make sure we get latest/most relevant version\n and make sure we get latest/most relevant version\n
should be reimplemented in SQL some sunny day.\n should be reimplemented in SQL some sunny day.\n
"""\n """\n
reference = context.getReference()\n
if reference is None:\n
return ()\n
\n \n
search_term_list = []\n return context.Base_zGetImplicitPredecessorValueList(reference=reference)\n
\n
if context.getReference() is None: \n
return []\n
\n
search_term_list.append(context.getReference())\n
\n
if context.getLanguage() is not None:\n
search_term_list.append(context.getReference() + \'-\' + context.getLanguage())\n
if context.getVersion() is not None:\n
search_term_list.append(context.getReference() + \'-\' + context.getLanguage() + \'-\' + context.getVersion())\n
\n
# Find from only document types\n
document_type_list = context.getPortalDocumentTypeList()\n
\n
kw = {}\n
searchable_text_list = []\n
for term in search_term_list:\n
searchable_text_list.append(\'%\'+term+\'%\')\n
kw[\'full_text.SearchableText\'] = searchable_text_list\n
result = context.portal_catalog(portal_type=document_type_list, **kw)\n
\n
return result\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -149,17 +127,10 @@ return result\n ...@@ -149,17 +127,10 @@ return result\n
<tuple> <tuple>
<string>a</string> <string>a</string>
<string>kw</string> <string>kw</string>
<string>search_term_list</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>reference</string>
<string>None</string> <string>None</string>
<string>document_type_list</string>
<string>searchable_text_list</string>
<string>_getiter_</string>
<string>term</string>
<string>_write_</string>
<string>_apply_</string>
<string>result</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<string>Products.PythonScripts.PythonScript</string> <tuple/>
<string>PythonScript</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -68,9 +65,7 @@ ...@@ -68,9 +65,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>"""\n
"""\n
Called by document.getImplicitSuccessorValueList\n Called by document.getImplicitSuccessorValueList\n
Gets a list of dicts containing reference and/or version and/or language\n Gets a list of dicts containing reference and/or version and/or language\n
and maybe some more things.\n and maybe some more things.\n
...@@ -79,34 +74,20 @@ ...@@ -79,34 +74,20 @@
dummy simple implementation - if no version, then return the newest in the chosen language\n dummy simple implementation - if no version, then return the newest in the chosen language\n
or in any language if not specified\n or in any language if not specified\n
"""\n """\n
my_reference = context.getReference()\n
temporary_dict = {}\n
for dic in reference_list:\n
reference = dic.get(\'reference\')\n
if reference is not None and reference!=my_reference:\n
temporary_dict[reference] = None\n
\n \n
def findDocByReferenceDict(ref_dict):\n if not temporary_dict:\n
reference=ref_dict.get(\'reference\')\n return ()\n
if reference is None:\n
return\n
# assuming we want only the highest version:\n
searchargs = dict(reference=reference, portal_type=context.getPortalDocumentTypeList(), sort_on=\'version\', sort_order=\'descending\')\n
language = ref_dict.get(\'language\')\n
if language is not None:\n
searchargs[\'language\'] = language\n
version = ref_dict.get(\'version\')\n
if version is not None:\n
searchargs[\'version\']=version\n
res = list(context.portal_catalog(**searchargs))\n
if len(res)>0:\n
return res[0]\n
\n
res = []\n
\n \n
for ref_dict in reference_list:\n # For the present, we only use reference.\n
ob = findDocByReferenceDict(ref_dict)\n # Result document will be the latest version with appropriate language by user setting.)\n
if ob is not None:\n return context.Base_zGetImplicitSuccessorValueList(reference_list=temporary_dict.keys())\n
res.append(ob)\n </string> </value>
\n
return [r for r in res if r.getUid()!=context.getUid()]\n
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -155,17 +136,15 @@ return [r for r in res if r.getUid()!=context.getUid()]\n ...@@ -155,17 +136,15 @@ return [r for r in res if r.getUid()!=context.getUid()]\n
<value> <value>
<tuple> <tuple>
<string>reference_list</string> <string>reference_list</string>
<string>findDocByReferenceDict</string>
<string>res</string>
<string>_getiter_</string>
<string>ref_dict</string>
<string>ob</string>
<string>None</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>append</string>
<string>$append0</string>
<string>r</string>
<string>context</string> <string>context</string>
<string>my_reference</string>
<string>temporary_dict</string>
<string>_getiter_</string>
<string>dic</string>
<string>reference</string>
<string>None</string>
<string>_write_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>reference</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>reference</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>reference\r\n
</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value> <string>ZSQLCatalog.zsqlbrain</string> </value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value> <string>ZSQLBrain</string> </value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_zGetImplicitPredecessorValueList</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
SET @current_path = \'\'; <dtml-var "\'\\0\'">\n
SET @current_reference = \'\'; <dtml-var "\'\\0\'">\n
\n
<dtml-let query="portal_catalog.buildSQLQuery(query=portal_catalog.getSecurityQuery(), portal_type=getPortalDocumentTypeList())">\n
<dtml-let user_language="Localizer.get_selected_language()">\n
SELECT path, uid\n
FROM\n
(\n
SELECT DISTINCT\n
path,\n
(select uid from catalog where catalog.path=sub.path) as uid\n
FROM\n
( SELECT\n
@current_path:=IF(@current_reference = reference, @current_path, path) AS path,\n
@current_reference:=reference AS reference\n
FROM (\n
SELECT\n
reference,\n
path,\n
catalog.uid,\n
CASE language WHEN <dtml-sqlvar user_language type=string> THEN 1 WHEN \'en\' THEN 0 ELSE -1 END as language_order\n
FROM\n
catalog, versioning, full_text\n
WHERE\n
catalog.uid = versioning.uid\n
AND\n
catalog.uid = full_text.uid\n
<dtml-if "query[\'where_expression\']">\n
AND <dtml-var "query[\'where_expression\']">\n
</dtml-if>\n
AND\n
<dtml-sqltest "\'%\'+str(reference)+\'%\'" column=SearchableText op=like type=string>\n
AND\n
<dtml-sqltest reference op=ne type=string>\n
ORDER BY reference, language_order DESC, version DESC\n
) AS innersub\n
)\n
AS sub\n
)\n
AS main\n
WHERE\n
<dtml-sqltest "getUid()" column=uid op=ne type=int>\n
LIMIT 1000\n
\n
</dtml-let>\n
</dtml-let>\n
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="__newobj__" module="copy_reg"/>
</klass>
<tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
SET @current_path = \'\'; <dtml-var "\'\\0\'">\n
SET @current_reference = \'\'; <dtml-var "\'\\0\'">\n
\n
<dtml-let query="portal_catalog.buildSQLQuery(query=portal_catalog.getSecurityQuery(), portal_type=getPortalDocumentTypeList())">\n
<dtml-let user_language="Localizer.get_selected_language()">\n
SELECT path, uid\n
FROM\n
(\n
SELECT DISTINCT\n
path,\n
(select uid from catalog where catalog.path=sub.path) as uid\n
FROM\n
( SELECT\n
@current_path:=IF(@current_reference = reference, @current_path, path) AS path,\n
@current_reference:=reference AS reference\n
FROM (\n
SELECT\n
reference,\n
path,\n
catalog.uid,\n
CASE language WHEN <dtml-sqlvar user_language type=string> THEN 1 WHEN \'en\' THEN 0 ELSE -1 END as language_order\n
FROM\n
catalog, versioning, full_text\n
WHERE\n
catalog.uid = versioning.uid\n
AND\n
catalog.uid = full_text.uid\n
<dtml-if "query[\'where_expression\']">\n
AND <dtml-var "query[\'where_expression\']">\n
</dtml-if>\n
AND\n
<dtml-sqltest "\'%\'+str(reference)+\'%\'" column=SearchableText op=like type=string>\n
AND\n
<dtml-sqltest reference op=ne type=string>\n
ORDER BY reference, language_order DESC, version DESC\n
) AS innersub\n
)\n
AS sub\n
)\n
AS main\n
WHERE\n
<dtml-sqltest "getUid()" column=uid op=ne type=int>\n
LIMIT 1000\n
\n
</dtml-let>\n
</dtml-let>\n
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>reference_list</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>reference_list</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>reference_list\r\n
</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value> <string>ZSQLCatalog.zsqlbrain</string> </value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value> <string>ZSQLBrain</string> </value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_zGetImplicitSuccessorValueList</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
SET @current_path = \'\'; <dtml-var "\'\\0\'">\n
SET @current_reference = \'\'; <dtml-var "\'\\0\'">\n
\n
<dtml-let query="portal_catalog.buildSQLQuery(query=portal_catalog.getSecurityQuery(), portal_type=getPortalDocumentTypeList())">\n
<dtml-let user_language="Localizer.get_selected_language()">\n
SELECT path, uid\n
FROM\n
(\n
SELECT DISTINCT\n
path,\n
(select uid from catalog where catalog.path=sub.path) as uid\n
FROM\n
( SELECT\n
@current_path:=IF(@current_reference = reference, @current_path, path) AS path,\n
@current_reference:=reference AS reference\n
FROM (\n
SELECT\n
reference,\n
path,\n
catalog.uid,\n
CASE language WHEN <dtml-sqlvar user_language type=string> THEN 1 WHEN \'en\' THEN 0 ELSE -1 END as language_order\n
FROM\n
catalog, versioning\n
WHERE\n
catalog.uid = versioning.uid\n
<dtml-if "query[\'where_expression\']">\n
AND <dtml-var "query[\'where_expression\']">\n
</dtml-if>\n
AND\n
(\n
<dtml-in reference_list>\n
<dtml-sqltest "_[\'sequence-item\']" column=reference op=eq type=string>\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n
)\n
ORDER BY reference, language_order DESC, version DESC\n
) AS innersub\n
)\n
AS sub\n
)\n
AS main\n
WHERE\n
<dtml-sqltest "getUid()" column=uid op=ne type=int>\n
LIMIT 1000\n
\n
</dtml-let>\n
</dtml-let>\n
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="__newobj__" module="copy_reg"/>
</klass>
<tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
SET @current_path = \'\'; <dtml-var "\'\\0\'">\n
SET @current_reference = \'\'; <dtml-var "\'\\0\'">\n
\n
<dtml-let query="portal_catalog.buildSQLQuery(query=portal_catalog.getSecurityQuery(), portal_type=getPortalDocumentTypeList())">\n
<dtml-let user_language="Localizer.get_selected_language()">\n
SELECT path, uid\n
FROM\n
(\n
SELECT DISTINCT\n
path,\n
(select uid from catalog where catalog.path=sub.path) as uid\n
FROM\n
( SELECT\n
@current_path:=IF(@current_reference = reference, @current_path, path) AS path,\n
@current_reference:=reference AS reference\n
FROM (\n
SELECT\n
reference,\n
path,\n
catalog.uid,\n
CASE language WHEN <dtml-sqlvar user_language type=string> THEN 1 WHEN \'en\' THEN 0 ELSE -1 END as language_order\n
FROM\n
catalog, versioning\n
WHERE\n
catalog.uid = versioning.uid\n
<dtml-if "query[\'where_expression\']">\n
AND <dtml-var "query[\'where_expression\']">\n
</dtml-if>\n
AND\n
(\n
<dtml-in reference_list>\n
<dtml-sqltest "_[\'sequence-item\']" column=reference op=eq type=string>\n
<dtml-unless sequence-end> OR </dtml-unless>\n
</dtml-in>\n
)\n
ORDER BY reference, language_order DESC, version DESC\n
) AS innersub\n
)\n
AS sub\n
)\n
AS main\n
WHERE\n
<dtml-sqltest "getUid()" column=uid op=ne type=int>\n
LIMIT 1000\n
\n
</dtml-let>\n
</dtml-let>\n
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2008-2-14 Yusei
* Improve wiki successor/predecessor.
2008-1-16 Yusei 2008-1-16 Yusei
* Added generic pdf viewer for pdf preview. * Added generic pdf viewer for pdf preview.
......
847 849
\ 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