Commit 195cbb89 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

improve Base_getRelatedDocumentList so as not to return same documents twice,...

improve Base_getRelatedDocumentList so as not to return same documents twice, and to support other parameters like sorting, still calling portal_catalog twice.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36265 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d1f4b212
......@@ -53,24 +53,18 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>kw.pop(\'relative_url\', None)\n
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
kw.pop(\'relative_url\', None)\n
kw.pop(\'follow_up_uid\', None)\n
\n
sub_document_list = context.portal_catalog(\n
portal_type=portal_type,\n
relative_url=\'%s/%%\' % context.getRelativeUrl(), **kw)\n
\n
follow_up_related_document_list = context.portal_catalog(\n
portal_catalog=context.getPortalObject().portal_catalog\n
follow_up_related_document_list = portal_catalog(\n
portal_type=portal_type,\n
follow_up_uid=context.getUid(), **kw)\n
\n
if not sub_document_list:\n
return follow_up_related_document_list\n
\n
if not follow_up_related_document_list:\n
return sub_document_list\n
\n
return [doc for doc in follow_up_related_document_list] + [doc for doc in sub_document_list]\n
kw[\'query\'] = ComplexQuery(\n
Query(relative_url=\'%s/%%\' % context.getRelativeUrl()),\n
Query(uid=[x.getUid() for x in follow_up_related_document_list]),\n
operator=\'or\')\n
return portal_catalog(portal_type=portal_type, **kw)\n
</string> </value>
</item>
<item>
......@@ -109,16 +103,20 @@ return [doc for doc in follow_up_related_document_list] + [doc for doc in sub_do
<tuple>
<string>portal_type</string>
<string>kw</string>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>ComplexQuery</string>
<string>_getattr_</string>
<string>None</string>
<string>_apply_</string>
<string>context</string>
<string>sub_document_list</string>
<string>portal_catalog</string>
<string>_apply_</string>
<string>follow_up_related_document_list</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>doc</string>
<string>x</string>
<string>_write_</string>
</tuple>
</value>
</item>
......
1609
\ No newline at end of file
1610
\ 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