--- a/src/pyams_content/shared/view/__init__.py Tue Jun 27 15:10:36 2017 +0200
+++ b/src/pyams_content/shared/view/__init__.py Wed Jun 28 12:09:57 2017 +0200
@@ -55,8 +55,9 @@
selected_content_types = FieldProperty(IWfView['selected_content_types'])
order_by = FieldProperty(IWfView['order_by'])
reversed_order = FieldProperty(IWfView['reversed_order'])
+ limit = FieldProperty(IWfView['limit'])
- def get_results(self, context, limit=None):
+ def get_results(self, context):
intids = get_utility(IIntIds)
views_cache = get_cache(VIEWS_CACHE_REGION, VIEWS_CACHE_NAME)
cache_key = VIEWS_CACHE_KEY.format(view=intids.queryId(self),
@@ -68,7 +69,7 @@
adapter = registry.queryAdapter(self, IViewQuery, name='es')
if adapter is None:
adapter = registry.getAdapter(self, IViewQuery)
- results = adapter.get_results(context)
+ results = adapter.get_results(context, self.limit)
views_cache.set_value(cache_key, [intids.queryId(item) for item in results])
logger.debug("Storing view items to cache key {0}".format(cache_key))
else:
--- a/src/pyams_content/shared/view/interfaces/__init__.py Tue Jun 27 15:10:36 2017 +0200
+++ b/src/pyams_content/shared/view/interfaces/__init__.py Wed Jun 28 12:09:57 2017 +0200
@@ -20,10 +20,9 @@
from pyams_content.shared.common.interfaces import ISharedContent, IWfSharedContent, ISharedTool
# import packages
-from pyams_sequence.schema import InternalReferencesList
from pyams_thesaurus.schema import ThesaurusTermsListField
from zope.interface import Interface, Attribute
-from zope.schema import List, Choice, Bool
+from zope.schema import List, Choice, Bool, Int
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from pyams_content import _
@@ -70,6 +69,10 @@
required=True,
default=True)
+ limit = Int(title=_("Results count limit"),
+ description=_("Maximum number of results that the view may retrieve"),
+ required=False)
+
def get_results(self, context):
"""Get results of catalog query"""
@@ -81,7 +84,7 @@
class IViewQuery(Interface):
"""View query interface"""
- def get_results(self, context):
+ def get_results(self, context, limit=None):
"""Get results of catalog query"""
--- a/src/pyams_content/shared/view/zmi/properties.py Tue Jun 27 15:10:36 2017 +0200
+++ b/src/pyams_content/shared/view/zmi/properties.py Wed Jun 28 12:09:57 2017 +0200
@@ -38,5 +38,5 @@
legend = _("Contents search settings")
fieldset_class = 'bordered no-x-margin margin-y-10'
- fields = field.Fields(IWfView).select('selected_content_types', 'order_by', 'reversed_order')
+ fields = field.Fields(IWfView).select('selected_content_types', 'order_by', 'reversed_order', 'limit')
weight = 1