本文整理汇总了Python中plone.app.collection.interfaces.ICollection.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python ICollection.providedBy方法的具体用法?Python ICollection.providedBy怎么用?Python ICollection.providedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.app.collection.interfaces.ICollection
的用法示例。
在下文中一共展示了ICollection.providedBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queryCatalog
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def queryCatalog(self, limit):
"""
"""
querybuilder = QueryBuilder(self, self.request)
if not hasattr(self.data, 'sort_on'):
self.data.sort_on = 'effective'
if not hasattr(self.data, 'sort_order'):
self.data.sort_order = False
if not hasattr(self.data, 'sort_folderorder'):
self.data.sort_folderorder = False
sort_order = 'descending' if self.data.sort_order else 'ascending'
sort_on = self.data.sort_on
if self.data.sort_folderorder:
sort_on = 'getObjPositionInParent'
query = list(self.data.query)
if ICollection.providedBy(self.context):
query += self.context.query and self.context.query or []
parent = aq_parent(aq_inner(self.context))
if ICollection.providedBy(parent):
query += parent.query and parent.query or []
return querybuilder(query=query,
sort_on=sort_on,
sort_order=sort_order,
limit=limit)
示例2: walk
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def walk(items, result, parent):
for item in items:
collection = []
if COLLECTION and IContentListingObject.providedBy(item):
item = item.getObject()
elif IATTopic.providedBy(item):
collection = item.queryCatalog(b_size=100, full_objects=True)
elif COLLECTION and ICollection.providedBy(item):
collection = item.getQuery()
if collection:
result[item.title_or_id()] = []
walk(collection, result, item.title_or_id())
else:
# add only published items
if wft.getInfoFor(item, "review_state") != "published":
IStatusMessage(self.request).\
add(_(u'Some of the items in your list are private. '
'They were not included in the wizard - '
'MailChimp supports only published content.'),
type='error')
continue
result[parent].append({'uid': IUUID(item),
'title': item.title_or_id()})
return result
示例3: contentsMethod
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def contentsMethod(self):
context = aq_inner(self.context)
if IATTopic.providedBy(context) or ICollection.providedBy(context):
contentsMethod = context.queryCatalog
else:
contentsMethod = context.getFolderContents
return contentsMethod
示例4: get_items
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def get_items(self):
context = aq_inner(self.context)
if IATFolder.providedBy(context) or \
IATBTreeFolder.providedBy(context):
res = self.context.getFolderContents(
contentFilter={
'sort_on': 'getObjPositionInParent',
'portal_type': self.settings.allowed_types,
'limit': self.settings.limit
}
)
elif IATTopic.providedBy(context):
if self.settings.limit and self.settings.limit > 0:
res = context.queryCatalog(batch=True,
b_size=self.settings.limit,
portal_type=
self.settings.allowed_types,
)
else:
res = context.queryCatalog(
portal_type=self.settings.allowed_types,
limit=self.settings.limit
)
elif ICollection.providedBy(context):
query = queryparser.parseFormquery(
context, context.getRawQuery())
query['portal_type'] = self.settings.allowed_types
query['limit'] = self.settings.limit
if self.settings.limit and self.settings.limit > 0:
res = context.queryCatalog(batch=True,
b_size=self.settings.limit)
else:
res = context.queryCatalog(query)
return res
示例5: editCarouselLink
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def editCarouselLink(self):
provider = self.collection()
if provider is not None:
if ICollection.providedBy(provider):
return provider.absolute_url() + '/edit'
return provider.absolute_url() + '/criterion_edit_form'
return None
示例6: getCriteriaKeys
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def getCriteriaKeys(self):
li = []
if IATTopic.providedBy(self.context) or ICollection.providedBy(self.context) or IDXCollection.providedBy(self.context):
criteria = IListBaseQueryCriteria(self.context)()
for criterion in [a['i'] for a in criteria]:
li.append(self.name+'.'+criterion)
return li
示例7: __call__
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def __call__(self, context, **query):
ctool = getToolByName(context, 'portal_faceted', None)
if ctool:
search = ctool.search
else:
logger.debug('portal_faceted not present, using portal_catalog')
ctool = getToolByName(context, 'portal_catalog')
search = ctool.searchResults
# Also get query from Topic
buildQuery = getattr(context, 'buildQuery', None)
newquery = buildQuery and buildQuery() or {}
formquery = None
# Get query from Collection
if HAS_PAT:
if PACI.ICollection.providedBy(context):
infos = ICollection_behavior(context)
sort_order = ('descending'
if infos.sort_reversed
else 'ascending')
sort_on = infos.sort_on
formquery = infos.query
if ICollection.providedBy(context):
getRawQuery = getattr(context, 'getRawQuery', lambda: [])
formquery = getRawQuery()
getSortOn = getattr(context, 'getSort_on', lambda: None)
sort_on = getSortOn()
if sort_on:
getSortReversed = getattr(
context, 'getSort_reversed', lambda: None)
sort_order = getSortReversed()
if sort_order:
sort_order = 'descending'
else:
sort_order = 'ascending'
else:
sort_order = None
if formquery is not None:
newquery = parseFormquery(context, formquery, sort_on, sort_order)
if not isinstance(newquery, dict):
newquery = {}
# Avoid mixing sorting params from faceted and collection
if 'sort_on' not in query:
query.pop('sort_order', None)
if 'sort_on' in query and 'sort_order' not in query:
newquery.pop('sort_order', None)
newquery.update(query)
notify(QueryWillBeExecutedEvent(context, newquery))
return search(**newquery)
示例8: available
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def available(self):
# only show on collection/topic
if not self.context.restrictedTraverse('@@iscalendarlayout')():
return False
if ICollection.providedBy(self.context):
return True
if IATTopic.providedBy(self.context):
return True
return False
示例9: get_collection_query
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def get_collection_query(obj):
""" return collection's query params
"""
if IATTopic.providedBy(obj):
# old style collection
return obj.buildQuery()
if ICollection.providedBy(obj):
# new style collection
return parse_new_collection_query(obj)
示例10: edit_collection
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def edit_collection(self):
provider = self.collection()
smanager = SecurityManagement.getSecurityManager()
allowed = smanager.checkPermission(ChangeTopics, provider)
if allowed:
provider = self.collection()
if provider is not None:
if ICollection.providedBy(provider):
return provider.absolute_url() + '/edit'
return provider.absolute_url() + '/criterion_edit_form'
return None
示例11: results
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def results(self, batch=True, b_start=0, b_size=None, inherit=False, extra=[]):
querybuilder = QueryBuilder(self, self.REQUEST)
sort_order = 'reverse' if self.sort_reversed else 'ascending'
if not b_size:
b_size = self.item_count
query = isinstance(self.query, list) and deepcopy(self.query) or []
if inherit:
parent = aq_parent(self)
if ICollection.providedBy(parent):
query += parent.query and deepcopy(parent.query) or []
inparent = aq_parent(self)
if ICollection.providedBy(inparent):
query += inparent.query and deepcopy(inparent.query) or []
query = query + extra
res = querybuilder(
query=query,
batch=batch, b_start=b_start, b_size=b_size,
sort_on=self.sort_on, sort_order=sort_order,
limit=self.limit)
return res
示例12: getCollection
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def getCollection(self, item):
col = item.getCollection()
if item.limit > 0:
if HAS_COLLECTIONS and ICollection.providedBy(col) or \
HAS_PAC and IDXCollection.providedBy(col):
results = col.queryCatalog(b_size=item.limit)
else:
results = col.queryCatalog(sort_limit=item.limit)[:item.limit]
else:
results = col.queryCatalog()
return results
示例13: results
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def results(self, provider):
results = []
if provider is not None:
# by default we assume that only Collections are addable
# as a carousel provider
# It doesn't make sense to show *all* objects from a collection
# - some of them might return hundreeds of objects
if ICollection.providedBy(provider):
res = provider.results(b_size=7)
return res
return provider.queryCatalog()[:7]
return results
示例14: getEventsForCalendar
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def getEventsForCalendar(self):
navigation_root_path = self.root()
self.options = {}
if navigation_root_path:
root_content = self.rootTopic()
if root_content:
if IATTopic.providedBy(root_content):
self.options = root_content.buildQuery()
elif ICollection.providedBy(root_content):
self.options = parseFormquery(root_content, root_content.getField('query').getRaw(root_content))
_define_search_options(self, self.options)
weeks = self._get_calendar_structure()
return weeks
示例15: results
# 需要导入模块: from plone.app.collection.interfaces import ICollection [as 别名]
# 或者: from plone.app.collection.interfaces.ICollection import providedBy [as 别名]
def results(self, provider):
results = []
if provider is not None:
# by default we assume that only Collections are addable
# as a carousel provider
# It doesn't make sense to show *all* objects from a collection
# - some of them might return hundreeds of objects
registry = getUtility(IRegistry)
carousel_viewlet_max_size = registry.forInterface(
ICarouselSettings, False).carousel_viewlet_max_size or 7
if ICollection.providedBy(provider):
res = provider.results(b_size=carousel_viewlet_max_size)
return res
return provider.queryCatalog()[:carousel_viewlet_max_size]
return results