--- a/src/pyams_content/root/zmi/__init__.py Thu Jun 28 12:50:07 2018 +0200
+++ b/src/pyams_content/root/zmi/__init__.py Mon Jul 02 17:09:34 2018 +0200
@@ -51,7 +51,7 @@
from pyams_skin.viewlet.menu import MenuItem
from pyams_template.template import template_config
from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter, ContextRequestAdapter
-from pyams_utils.list import unique
+from pyams_utils.list import unique_iter
from pyams_utils.registry import get_utility, get_all_utilities_registered_for
from pyams_viewlet.manager import viewletmanager_config
from pyams_viewlet.viewlet import viewlet_config
@@ -175,11 +175,11 @@
Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
Any(catalog['workflow_state'], workflow.waiting_states)
params = params | query if params else query
- return filter(self.check_access,
- unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
- key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date')))))
+ yield from filter(self.check_access,
+ unique_iter(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
+ key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date')))))
def check_access(self, content):
if self.request.has_permission(MANAGE_SITE_ROOT_PERMISSION, context=content):
@@ -223,10 +223,10 @@
Any(catalog['workflow_state'], workflow.waiting_states) & \
Eq(catalog['workflow_principal'], self.request.principal.id)
params = params | query if params else query
- return unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
- key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date'))))
+ yield from unique_iter(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
+ key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date'))))
#
@@ -262,11 +262,11 @@
Or(Eq(catalog['role:owner'], self.request.principal.id),
Eq(catalog['role:contributor'], self.request.principal.id)))
params = params | query if params else query
- return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- limit=50,
- sort_index='modified_date',
- reverse=True))))
+ yield from unique_iter(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ limit=50,
+ sort_index='modified_date',
+ reverse=True))))
#
@@ -323,10 +323,10 @@
Any(catalog['content_type'], CONTENT_TYPES.keys()),
Any(catalog['oid'], profile.favorites or ()))
params = params | query if params else query
- return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True))))
+ yield from unique_iter(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True))))
@pagelet_config(name='my-favorites.html', context=ISiteRoot, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -386,9 +386,9 @@
Eq(catalog['role:contributor'], self.request.principal.id)),
Eq(catalog['workflow_state'], workflow.initial_state))
params = params | query if params else query
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='my-preparations.html', context=ISiteRoot, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -448,9 +448,9 @@
Eq(catalog['role:contributor'], self.request.principal.id)),
Any(catalog['workflow_state'], workflow.waiting_states))
params = params | query if params else query
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='my-submissions.html', context=ISiteRoot, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -510,9 +510,9 @@
Eq(catalog['role:contributor'], self.request.principal.id)),
Any(catalog['workflow_state'], workflow.published_states))
params = params | query if params else query
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='my-publications.html', context=ISiteRoot, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -572,9 +572,9 @@
Eq(catalog['role:contributor'], self.request.principal.id)),
Any(catalog['workflow_state'], workflow.retired_states))
params = params | query if params else query
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='my-retired-contents.html', context=ISiteRoot, layer=IPyAMSLayer,
@@ -636,14 +636,14 @@
Eq(catalog['role:contributor'], principal_id)),
Any(catalog['workflow_state'], workflow.archived_states))
params = params | query if params else query
- return unique(map(lambda x: sorted((version for version in
- IWorkflowVersions(x).get_versions(IWorkflow(x).archived_states)
- if principal_id in (version.owner | version.contributors)),
- key=lambda x: IWorkflowState(x).version_id,
- reverse=True)[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True))))
+ yield from unique_iter(map(lambda x: sorted((version for version in
+ IWorkflowVersions(x).get_versions(IWorkflow(x).archived_states)
+ if principal_id in (version.owner | version.contributors)),
+ key=lambda x: IWorkflowState(x).version_id,
+ reverse=True)[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True))))
@pagelet_config(name='my-archived-contents.html', context=ISiteRoot, layer=IPyAMSLayer,
@@ -724,10 +724,10 @@
Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
Any(catalog['workflow_state'], workflow.published_states))
params = params | query if params else query
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- limit=50,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ limit=50,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='all-publications.html', context=ISiteRoot, layer=IPyAMSLayer,
@@ -790,10 +790,10 @@
query = Eq(catalog['parents'], intids.register(tool)) & \
Any(catalog['content_type'], CONTENT_TYPES.keys())
params = params | query if params else query
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- limit=50,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ limit=50,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='all-updates.html', context=ISiteRoot, layer=IPyAMSLayer,
--- a/src/pyams_content/shared/common/zmi/dashboard.py Thu Jun 28 12:50:07 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/dashboard.py Mon Jul 02 17:09:34 2018 +0200
@@ -52,7 +52,7 @@
from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
from pyams_utils.date import format_datetime, SH_DATETIME_FORMAT
from pyams_utils.fanstatic import get_resource_path
-from pyams_utils.list import unique
+from pyams_utils.list import unique_iter
from pyams_utils.property import cached_property
from pyams_utils.registry import get_utility
from pyams_utils.timezone import tztime
@@ -342,11 +342,11 @@
params = Eq(catalog['parents'], intids.register(self.context)) & \
Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
Any(catalog['workflow_state'], workflow.waiting_states)
- return filter(self.check_access,
- unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
- key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date')))))
+ yield from filter(self.check_access,
+ unique_iter(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
+ key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date')))))
def check_access(self, content):
if self.request.has_permission(MANAGE_SITE_ROOT_PERMISSION, context=content):
@@ -387,10 +387,10 @@
Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
Any(catalog['workflow_state'], workflow.waiting_states) & \
Eq(catalog['workflow_principal'], self.request.principal.id)
- return unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
- key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date'))))
+ yield from unique_iter(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
+ key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date'))))
#
@@ -423,12 +423,12 @@
Any(catalog['content_type'], CONTENT_TYPES.keys()),
Or(Eq(catalog['role:owner'], self.request.principal.id),
Eq(catalog['role:contributor'], self.request.principal.id)))
- return unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
- key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- limit=50,
- sort_index='modified_date',
- reverse=True))))
+ yield from unique_iter(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state),
+ key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ limit=50,
+ sort_index='modified_date',
+ reverse=True))))
#
@@ -518,10 +518,10 @@
params = And(Eq(catalog['parents'], intids.register(self.context)),
Any(catalog['content_type'], CONTENT_TYPES.keys()),
Any(catalog['oid'], profile.favorites or ()))
- return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True))))
+ yield from unique_iter(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True))))
@pagelet_config(name='my-favorites.html', context=IBaseSharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -582,9 +582,9 @@
Or(Eq(catalog['role:owner'], self.request.principal.id),
Eq(catalog['role:contributor'], self.request.principal.id)),
Eq(catalog['workflow_state'], workflow.initial_state))
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='my-preparations.html', context=IBaseSharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -645,9 +645,9 @@
Or(Eq(catalog['role:owner'], self.request.principal.id),
Eq(catalog['role:contributor'], self.request.principal.id)),
Any(catalog['workflow_state'], workflow.waiting_states))
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='my-submissions.html', context=IBaseSharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -708,9 +708,9 @@
Or(Eq(catalog['role:owner'], self.request.principal.id),
Eq(catalog['role:contributor'], self.request.principal.id)),
Any(catalog['workflow_state'], workflow.published_states))
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='my-publications.html', context=IBaseSharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
@@ -771,9 +771,9 @@
Or(Eq(catalog['role:owner'], self.request.principal.id),
Eq(catalog['role:contributor'], self.request.principal.id)),
Any(catalog['workflow_state'], workflow.retired_states))
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='my-retired-contents.html', context=IBaseSharedTool, layer=IPyAMSLayer,
@@ -836,14 +836,14 @@
Or(Eq(catalog['role:owner'], principal_id),
Eq(catalog['role:contributor'], principal_id)),
Any(catalog['workflow_state'], workflow.archived_states))
- return unique(map(lambda x: sorted((version for version in
- IWorkflowVersions(x).get_versions(workflow.archived_states)
- if principal_id in (version.owner | version.contributors)),
- key=lambda x: IWorkflowState(x).version_id,
- reverse=True)[0],
- CatalogResultSet(CatalogQuery(catalog).query(params,
- sort_index='modified_date',
- reverse=True))))
+ yield from unique_iter(map(lambda x: sorted((version for version in
+ IWorkflowVersions(x).get_versions(workflow.archived_states)
+ if principal_id in (version.owner | version.contributors)),
+ key=lambda x: IWorkflowState(x).version_id,
+ reverse=True)[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True))))
@pagelet_config(name='my-archived-contents.html', context=IBaseSharedTool, layer=IPyAMSLayer,
@@ -925,10 +925,10 @@
params = And(Eq(catalog['parents'], intids.register(self.context)),
Any(catalog['content_type'], CONTENT_TYPES.keys()) & \
Any(catalog['workflow_state'], workflow.published_states))
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- limit=50,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ limit=50,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='all-publications.html', context=IBaseSharedTool, layer=IPyAMSLayer,
@@ -992,10 +992,10 @@
catalog = get_utility(ICatalog)
params = Eq(catalog['parents'], intids.register(self.context)) & \
Any(catalog['content_type'], CONTENT_TYPES.keys())
- return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
- limit=50,
- sort_index='modified_date',
- reverse=True)))
+ yield from unique_iter(CatalogResultSet(CatalogQuery(catalog).query(params,
+ limit=50,
+ sort_index='modified_date',
+ reverse=True)))
@pagelet_config(name='all-updates.html', context=IBaseSharedTool, layer=IPyAMSLayer,