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 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......@@ -109,8 +106,8 @@ if not reference_list: return None # Quick return\n
# to some extend. This list takes into account some common\n
# state IDs used in ERP5.\n
return context.getDocumentValue(name=reference_list,\n
validation_state=[\'released\', \'published\', \'shared\',\n
\'public\', \'validated\', ])\n
validation_state=(\'released\', \'released_alive\', \'published\', \'published_alive\',\n
\'shared\', \'shared_alive\', \'public\', \'validated\'))\n
</string> </value>
</item>
<item>
......
......@@ -90,18 +90,21 @@ portal_catalog = portal.portal_catalog\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
# 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
# Find the applicable language\n
if kw.has_key(\'language\'):\n
language = kw[\'language\']\n
del kw[\'language\']\n
else:\n
if language is None:\n
language = portal.Localizer.get_selected_language()\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
# 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
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
......@@ -109,7 +112,9 @@ web_page_list = portal_catalog(reference=name, portal_type=valid_portal_type_lis
\n
if len(web_page_list) == 0 and language != \'en\':\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
order_by=[(\'version\', \'descending\')],\n
group_by=(\'reference\',),\n
......@@ -117,7 +122,9 @@ if len(web_page_list) == 0 and language != \'en\':\n
\n
if len(web_page_list) == 0:\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
group_by=(\'reference\',),\n
**kw)\n
......@@ -154,7 +161,7 @@ return web_page\n
</item>
<item>
<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>
<key> <string>errors</string> </key>
......@@ -174,7 +181,7 @@ return web_page\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -182,19 +189,19 @@ return web_page\n
<tuple>
<string>name</string>
<string>portal</string>
<string>language</string>
<string>validation_state</string>
<string>kw</string>
<string>None</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_catalog</string>
<string>valid_portal_type_list</string>
<string>_getitem_</string>
<string>language</string>
<string>_write_</string>
<string>_apply_</string>
<string>web_page_list</string>
<string>len</string>
<string>web_page</string>
<string>_getitem_</string>
</tuple>
</value>
</item>
......@@ -208,6 +215,8 @@ return web_page\n
<value>
<tuple>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
......
......@@ -112,22 +112,39 @@
\n
- Display only the latest version and the appropriate language.\n
"""\n
portal_catalog = container.portal_catalog\n
\n
# First find the Web Section or Web Site we belong to\n
current_section = context.getWebSectionValue()\n
\n
# Build the list of parameters\n
if not kw.has_key(\'validation_state\'):\n
kw[\'validation_state\'] = [\'draft\', \'submitted\', \'shared\',\n
\'released\', \'published\', \'restricted\']\n
if not kw.has_key(\'sort_on\'):\n
kw[\'sort_on\'] = [(\'int_index\', \'descending\')]\n
if not kw.has_key(\'group_by\'):\n
kw[\'group_by\'] = (\'reference\',)\n
\n
# Return the list of matching documents for the given states\n
return current_section.searchResults(**kw)\n
from zExceptions import Unauthorized\n
\n
try:\n
portal = container.getPortalObject()\n
portal_catalog = portal.portal_catalog\n
\n
# First find the Web Section or Web Site we belong to\n
current_section = context.getWebSectionValue()\n
\n
# Build the list of parameters\n
valid_portal_type_list = portal.getPortalDocumentTypeList()\n
\n
if language is None:\n
language = portal.Localizer.get_selected_language()\n
\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>
</item>
<item>
......@@ -150,7 +167,7 @@ return current_section.searchResults(**kw)\n
</item>
<item>
<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>
<key> <string>errors</string> </key>
......@@ -170,19 +187,27 @@ return current_section.searchResults(**kw)\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>language</string>
<string>validation_state</string>
<string>sort_on</string>
<string>group_by</string>
<string>kw</string>
<string>zExceptions</string>
<string>Unauthorized</string>
<string>_getattr_</string>
<string>container</string>
<string>portal</string>
<string>portal_catalog</string>
<string>context</string>
<string>current_section</string>
<string>_write_</string>
<string>valid_portal_type_list</string>
<string>None</string>
<string>_apply_</string>
</tuple>
</value>
......@@ -195,7 +220,12 @@ return current_section.searchResults(**kw)\n
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
<tuple>
<none/>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
......
2008-06-11 yo
* Make the scripts for retrieving documents more consistent.
2008-06-10 yo
* Add a field for text content substitutions.
......
640
\ No newline at end of file
641
\ 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