本文整理汇总了Python中plone.portlets.interfaces.IPortletContext.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python IPortletContext.providedBy方法的具体用法?Python IPortletContext.providedBy怎么用?Python IPortletContext.providedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.portlets.interfaces.IPortletContext
的用法示例。
在下文中一共展示了IPortletContext.providedBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getPortlets
# 需要导入模块: from plone.portlets.interfaces import IPortletContext [as 别名]
# 或者: from plone.portlets.interfaces.IPortletContext import providedBy [as 别名]
def getPortlets(self):
if IPortletContext.providedBy(self.context):
pcontext = self.context
else:
pcontext = queryAdapter(self.context, IPortletContext)
if pcontext is None:
return []
assignments = []
for category, key in pcontext.globalPortletCategories(True):
mapping = self.storage.get(category, None)
if mapping is not None:
for assignment in mapping.get(key, {}).values():
try:
settings = IPortletAssignmentSettings(assignment)
except TypeError:
# Portlet does not exist any longer
continue
else:
if not settings.get('visible', True):
continue
assignments.append({'category': category,
'key': key,
'name': assignment.__name__,
'assignment': assignment
})
return assignments
示例2: getPortlets
# 需要导入模块: from plone.portlets.interfaces import IPortletContext [as 别名]
# 或者: from plone.portlets.interfaces.IPortletContext import providedBy [as 别名]
def getPortlets(self):
if IPortletContext.providedBy(self.context):
pcontext = self.context
else:
pcontext = queryAdapter(self.context, IPortletContext)
if pcontext is None:
return []
assignments = []
for category, key in pcontext.globalPortletCategories(True):
mapping = self.storage.get(category, None)
if mapping is not None:
for assignment in mapping.get(key, {}).values():
try:
settings = IPortletAssignmentSettings(assignment)
except Exception:
logException(u'Error during retrieving assignment '
'settings. Context: "%s", Category: "%s", Key: '
'"%s", Assignment Class: "%s", Assignment ID: "%s"'
% ('/'.join(self.context.getPhysicalPath()),
category, key, str(assignment.__class__),
assignment.__name__), context=self.context)
continue
if not settings.get('visible', True):
continue
assignments.append({'category': category,
'key': key,
'name': assignment.__name__,
'assignment': assignment
})
return assignments
示例3: parent_blacklist_status
# 需要导入模块: from plone.portlets.interfaces import IPortletContext [as 别名]
# 或者: from plone.portlets.interfaces.IPortletContext import providedBy [as 别名]
def parent_blacklist_status(self, category):
if IPortletContext.providedBy(self.context):
pcontext = self.context
else:
pcontext = queryAdapter(self.context, IPortletContext)
status = None
current = pcontext.getParent()
currentpc = pcontext
while status is None and current is not None:
assignable = getMultiAdapter((current, self.manager,), ILocalPortletAssignmentManager)
status = assignable.getBlacklistStatus(category)
current = currentpc.getParent()
if current is not None:
if IPortletContext.providedBy(current):
currentpc = current
else:
currentpc = queryAdapter(current, IPortletContext)
return status
示例4: getPortlets
# 需要导入模块: from plone.portlets.interfaces import IPortletContext [as 别名]
# 或者: from plone.portlets.interfaces.IPortletContext import providedBy [as 别名]
def getPortlets(self):
portal_state = getMultiAdapter((self.context, self.context.REQUEST), name=u'plone_portal_state')
portal = portal_state.portal()
pcontext = IPortletContext(self.context, None)
if pcontext is None:
return []
categories = []
blacklisted = {}
manager = self.storage.__name__
for category, key in pcontext.globalPortletCategories(False):
blacklisted[category] = None
current = self.context
currentpc = pcontext
blacklistFetched = set()
parentsBlocked = False
while current is not None and currentpc is not None:
if ILocalPortletAssignable.providedBy(current):
assignable = current
else:
assignable = queryAdapter(current, ILocalPortletAssignable)
if assignable is not None:
if IAnnotations.providedBy(assignable):
annotations = assignable
else:
annotations = queryAdapter(assignable, IAnnotations)
if not parentsBlocked:
local = annotations.get(CONTEXT_ASSIGNMENT_KEY, None)
if local is not None:
localManager = local.get(manager, None)
if localManager is not None:
categories.extend([(CONTEXT_CATEGORY, currentpc.uid, a) for a in localManager.values()])
blacklistStatus = annotations.get(CONTEXT_BLACKLIST_STATUS_KEY, {}).get(manager, None)
if blacklistStatus is not None:
for cat, status in blacklistStatus.items():
if cat == CONTEXT_CATEGORY:
if not parentsBlocked and status == True:
parentsBlocked = True
else: # global portlet categories
if blacklisted.get(cat, False) is None:
blacklisted[cat] = status
if status is not None:
blacklistFetched.add(cat)
if parentsBlocked and len(blacklistFetched) == len(blacklisted):
break
current = currentpc.getParent()
if current is not None:
if IPortletContext.providedBy(current):
currentpc = current
else:
currentpc = queryAdapter(current, IPortletContext)
for category, key in pcontext.globalPortletCategories(False):
if not blacklisted[category]:
mapping = self.storage.get(category, None)
if mapping is not None:
for a in mapping.get(key, {}).values():
categories.append((category, key, a,))
managerUtility = getUtility(IPortletManager, manager, portal)
here_url = '/'.join(aq_inner(self.context).getPhysicalPath())
assignments = []
for category, key, assignment in categories:
assigned = ISolgemaPortletAssignment(assignment)
portletHash = hashPortletInfo(dict(manager=manager, category=category, key=key, name =assignment.__name__,))
if not getattr(assigned, 'stopUrls', False) or len([stopUrl for stopUrl in getattr(assigned, 'stopUrls', []) if stopUrl in here_url])==0:
assignments.append({'category' : category,
'key' : key,
'name' : assignment.__name__,
'assignment' : assignment,
'hash' : hashPortletInfo(dict(manager=manager, category=category, key=key, name =assignment.__name__,)),
'stopUrls' : ISolgemaPortletAssignment(assignment).stopUrls,
})
if hasattr(managerUtility, 'listAllManagedPortlets'):
hashlist = managerUtility.listAllManagedPortlets
assignments.sort(lambda a,b:cmp(hashlist.count(a['hash'])>0 and hashlist.index(a['hash']) or 0, hashlist.count(b['hash'])>0 and hashlist.index(b['hash']) or 0))
return assignments