Commit 9c070c26 authored by Yoshinori Okuji's avatar Yoshinori Okuji

2008-06-11 yo

* Make the scripts for retrieving documents more consistent.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21485 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0f3d7ec0
...@@ -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>
...@@ -109,8 +106,8 @@ if not reference_list: return None # Quick return\n ...@@ -109,8 +106,8 @@ if not reference_list: return None # Quick return\n
# to some extend. This list takes into account some common\n # to some extend. This list takes into account some common\n
# state IDs used in ERP5.\n # state IDs used in ERP5.\n
return context.getDocumentValue(name=reference_list,\n return context.getDocumentValue(name=reference_list,\n
validation_state=[\'released\', \'published\', \'shared\',\n validation_state=(\'released\', \'released_alive\', \'published\', \'published_alive\',\n
\'public\', \'validated\', ])\n \'shared\', \'shared_alive\', \'public\', \'validated\'))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -90,18 +90,21 @@ portal_catalog = portal.portal_catalog\n ...@@ -90,18 +90,21 @@ portal_catalog = portal.portal_catalog\n
# The list of portal types here should be large enough to include\n # The list of portal types here should be large enough to include\n
# all portal_types defined in the various sections so that\n # all portal_types defined in the various sections so that\n
# href tags which point to a document by reference can still work.\n # href tags which point to a document by reference can still work.\n
valid_portal_type_list = [\'Web Page\', ]\n valid_portal_type_list = portal.getPortalDocumentTypeList()\n
\n \n
# Find the applicable language\n # Find the applicable language\n
if kw.has_key(\'language\'):\n if language is None:\n
language = kw[\'language\']\n
del kw[\'language\']\n
else:\n
language = portal.Localizer.get_selected_language()\n language = portal.Localizer.get_selected_language()\n
\n \n
if validation_state is None:\n
validation_state = (\'released\', \'released_alive\', \'published\', \'published_alive\',\n
\'shared\', \'shared_alive\', \'public\', \'validated\')\n
\n
# Search the catalog for all documents matching the reference\n # Search the catalog for all documents matching the reference\n
# this will only return documents which are accessible by the user\n # this will only return documents which are accessible by the user\n
web_page_list = portal_catalog(reference=name, portal_type=valid_portal_type_list,\n web_page_list = portal_catalog(reference=name,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
language=language,\n language=language,\n
order_by=[(\'version\', \'descending\')],\n order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n group_by=(\'reference\',),\n
...@@ -109,7 +112,9 @@ web_page_list = portal_catalog(reference=name, portal_type=valid_portal_type_lis ...@@ -109,7 +112,9 @@ web_page_list = portal_catalog(reference=name, portal_type=valid_portal_type_lis
\n \n
if len(web_page_list) == 0 and language != \'en\':\n if len(web_page_list) == 0 and language != \'en\':\n
# Search again with English as a fallback.\n # Search again with English as a fallback.\n
web_page_list = portal_catalog(reference=name, portal_type=valid_portal_type_list,\n web_page_list = portal_catalog(reference=name,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
language=\'en\',\n language=\'en\',\n
order_by=[(\'version\', \'descending\')],\n order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n group_by=(\'reference\',),\n
...@@ -117,7 +122,9 @@ if len(web_page_list) == 0 and language != \'en\':\n ...@@ -117,7 +122,9 @@ if len(web_page_list) == 0 and language != \'en\':\n
\n \n
if len(web_page_list) == 0:\n if len(web_page_list) == 0:\n
# Search again without the language\n # Search again without the language\n
web_page_list = portal_catalog(reference=name, portal_type=\'Web Page\', \n web_page_list = portal_catalog(reference=name,\n
portal_type=valid_portal_type_list,\n
validation_state=validation_state,\n
order_by=[(\'version\', \'descending\')],\n order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n group_by=(\'reference\',),\n
**kw)\n **kw)\n
...@@ -154,7 +161,7 @@ return web_page\n ...@@ -154,7 +161,7 @@ return web_page\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>name, portal=None, **kw</string> </value> <value> <string>name, portal=None, language=None, validation_state=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -174,7 +181,7 @@ return web_page\n ...@@ -174,7 +181,7 @@ return web_page\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>4</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -182,19 +189,19 @@ return web_page\n ...@@ -182,19 +189,19 @@ return web_page\n
<tuple> <tuple>
<string>name</string> <string>name</string>
<string>portal</string> <string>portal</string>
<string>language</string>
<string>validation_state</string>
<string>kw</string> <string>kw</string>
<string>None</string> <string>None</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal_catalog</string> <string>portal_catalog</string>
<string>valid_portal_type_list</string> <string>valid_portal_type_list</string>
<string>_getitem_</string>
<string>language</string>
<string>_write_</string>
<string>_apply_</string> <string>_apply_</string>
<string>web_page_list</string> <string>web_page_list</string>
<string>len</string> <string>len</string>
<string>web_page</string> <string>web_page</string>
<string>_getitem_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -208,6 +215,8 @@ return web_page\n ...@@ -208,6 +215,8 @@ return web_page\n
<value> <value>
<tuple> <tuple>
<none/> <none/>
<none/>
<none/>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -112,22 +112,39 @@ ...@@ -112,22 +112,39 @@
\n \n
- Display only the latest version and the appropriate language.\n - Display only the latest version and the appropriate language.\n
"""\n """\n
portal_catalog = container.portal_catalog\n from zExceptions import Unauthorized\n
\n \n
# First find the Web Section or Web Site we belong to\n try:\n
current_section = context.getWebSectionValue()\n portal = container.getPortalObject()\n
\n portal_catalog = portal.portal_catalog\n
# Build the list of parameters\n \n
if not kw.has_key(\'validation_state\'):\n # First find the Web Section or Web Site we belong to\n
kw[\'validation_state\'] = [\'draft\', \'submitted\', \'shared\',\n current_section = context.getWebSectionValue()\n
\'released\', \'published\', \'restricted\']\n \n
if not kw.has_key(\'sort_on\'):\n # Build the list of parameters\n
kw[\'sort_on\'] = [(\'int_index\', \'descending\')]\n valid_portal_type_list = portal.getPortalDocumentTypeList()\n
if not kw.has_key(\'group_by\'):\n \n
kw[\'group_by\'] = (\'reference\',)\n if language is None:\n
\n language = portal.Localizer.get_selected_language()\n
# Return the list of matching documents for the given states\n \n
return current_section.searchResults(**kw)\n if validation_state is None:\n
validation_state = (\'released\', \'released_alive\', \'published\', \'published_alive\',\n
\'shared\', \'shared_alive\', \'public\', \'validated\')\n
if sort_on is None:\n
sort_on = [(\'int_index\', \'descending\')]\n
\n
if group_by is None:\n
group_by = (\'reference\',)\n
\n
# Return the list of matching documents for the given states\n
return current_section.searchResults(portal_type=valid_portal_type_list,\n
language=language,\n
validation_state=validation_state,\n
sort_on=sort_on,\n
group_by=group_by,\n
**kw)\n
except Unauthorized:\n
return []\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -150,7 +167,7 @@ return current_section.searchResults(**kw)\n ...@@ -150,7 +167,7 @@ return current_section.searchResults(**kw)\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>language=None, validation_state=None, sort_on=None, group_by=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -170,19 +187,27 @@ return current_section.searchResults(**kw)\n ...@@ -170,19 +187,27 @@ return current_section.searchResults(**kw)\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>0</int> </value> <value> <int>4</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>language</string>
<string>validation_state</string>
<string>sort_on</string>
<string>group_by</string>
<string>kw</string> <string>kw</string>
<string>zExceptions</string>
<string>Unauthorized</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>container</string> <string>container</string>
<string>portal</string>
<string>portal_catalog</string> <string>portal_catalog</string>
<string>context</string> <string>context</string>
<string>current_section</string> <string>current_section</string>
<string>_write_</string> <string>valid_portal_type_list</string>
<string>None</string>
<string>_apply_</string> <string>_apply_</string>
</tuple> </tuple>
</value> </value>
...@@ -195,7 +220,12 @@ return current_section.searchResults(**kw)\n ...@@ -195,7 +220,12 @@ return current_section.searchResults(**kw)\n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<none/> <tuple>
<none/>
<none/>
<none/>
<none/>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
2008-06-11 yo
* Make the scripts for retrieving documents more consistent.
2008-06-10 yo 2008-06-10 yo
* Add a field for text content substitutions. * Add a field for text content substitutions.
......
640 641
\ 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