Commit 09a43898 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

improve the performance in ERP5Site_getKnowledgePadListForUser.

parent 0903f18e
......@@ -55,16 +55,9 @@ isAnon = context.portal_membership.isAnonymousUser()\n
isAnonymousKnowledgePadUsed = request.get(\'is_anonymous_knowledge_pad_used\', 0);\n
from zExceptions import Unauthorized\n
\n
def safe_filter(func, list):\n
ret = []\n
append = ret.append\n
for e in list:\n
try:\n
if func(e):\n
append(e)\n
except Unauthorized:\n
pass\n
return ret\n
if default_pad_group == \'default_content_pad\':\n
raise\n
context.log(context.getRelativeUrl())\n
\n
def filterKnowledgePadListForContext(results, mode, \n
default_pad_group):\n
......@@ -74,19 +67,20 @@ def filterKnowledgePadListForContext(results, mode, \n
real_context = context\n
if context.getId() in context.Localizer.get_supported_languages():\n
real_context = context.getParentValue() \n
real_context_url = real_context.getRelativeUrl()\n
\n
if mode == \'erp5_front\':\n
# leave only those not having a publication_section as \n
# this means belonging to root\n
results = safe_filter(lambda x: x.getPublicationSection() is None and \\\n
results = filter(lambda x: x.getPublicationSection() is None and \\\n
x.getGroup() is None, results)\n
elif mode == \'web_front\':\n
# Web Site must at least one Pad referenced by context\n
results = safe_filter(lambda x: x.getPublicationSectionValue() == real_context and \\\n
results = filter(lambda x: x.getPublicationSection() == real_context_url and \\\n
x.getGroup() is None, results)\n
elif mode == \'web_section\':\n
# Web Sections, Web Pages can "reuse" tabs\n
results = safe_filter(lambda x: x.getPublicationSectionValue() == real_context or \\\n
results = filter(lambda x: x.getPublicationSection() == real_context_url or \\\n
x.getGroup() == default_pad_group, results)\n
return results\n
\n
......
725
\ No newline at end of file
726
\ 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