本文整理汇总了Python中Products.CMFPlone.interfaces.INonStructuralFolder.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python INonStructuralFolder.providedBy方法的具体用法?Python INonStructuralFolder.providedBy怎么用?Python INonStructuralFolder.providedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFPlone.interfaces.INonStructuralFolder
的用法示例。
在下文中一共展示了INonStructuralFolder.providedBy方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getRootPath
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def getRootPath(context, currentFolderOnly, topLevel, root):
"""Helper function to calculate the real root path
"""
context = aq_inner(context)
if currentFolderOnly:
folderish = getattr(aq_base(context), 'isPrincipiaFolderish', False) and not INonStructuralFolder.providedBy(context)
parent = aq_parent(context)
is_default_page = False
browser_default = IBrowserDefault(parent, None)
if browser_default is not None:
is_default_page = (browser_default.getDefaultPage() == context.getId())
if not folderish or is_default_page:
return '/'.join(parent.getPhysicalPath())
else:
return '/'.join(context.getPhysicalPath())
rootPath = getNavigationRoot(context, relativeRoot=root)
# Adjust for topLevel
if topLevel > 0:
contextPath = '/'.join(context.getPhysicalPath())
if not contextPath.startswith(rootPath):
return None
contextSubPathElements = contextPath[len(rootPath)+1:]
if contextSubPathElements:
contextSubPathElements = contextSubPathElements.split('/')
if len(contextSubPathElements) < topLevel:
return None
rootPath = rootPath + '/' + '/'.join(contextSubPathElements[:topLevel])
else:
return None
return rootPath
示例2: getIsPrincipiaFolderish
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def getIsPrincipiaFolderish(self):
refObject = self.getAlias()
if refObject is not None:
return (refObject.isPrincipiaFolderish
and not INonStructuralFolder.providedBy(refObject))
else:
return False
示例3: enabled
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def enabled(self):
context = aq_inner(self.context)
# Fetch discussion registry
# registry = queryUtility(IRegistry)
# settings = registry.forInterface(IDiscussionSettings, check=False)
#
# # Check if discussion is allowed globally
# if not settings.globally_enabled:
# return False
# Always return False if object is a folder
if (Iquestion.providedBy(context)):return True
if (IFolderish.providedBy(context) and
not INonStructuralFolder.providedBy(context)):
return False
def traverse_parents(context):
# Run through the aq_chain of obj and check if discussion is
# enabled in a parent folder.
for obj in aq_chain(context):
if not IPloneSiteRoot.providedBy(obj):
if (IFolderish.providedBy(obj) and
not INonStructuralFolder.providedBy(obj)):
flag = getattr(obj, 'allow_discussion', None)
if flag is not None:
return flag
return None
# If discussion is disabled for the object, bail out
obj_flag = getattr(aq_base(context), 'allow_discussion', None)
if obj_flag is False:
return False
# Check if traversal returned a folder with discussion_allowed set
# to True or False.
folder_allow_discussion = traverse_parents(context)
if folder_allow_discussion:
if not getattr(self, 'allow_discussion', None):
return True
else:
if obj_flag:
return True
# Check if discussion is allowed on the content type
portal_types = getToolByName(self, 'portal_types')
document_fti = getattr(portal_types, context.portal_type)
if not document_fti.getProperty('allow_discussion'):
# If discussion is not allowed on the content type,
# check if 'allow discussion' is overridden on the content object.
if not obj_flag:
return False
return True
示例4: traverse_parents
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def traverse_parents(context):
# Run through the aq_chain of obj and check if discussion is
# enabled in a parent folder.
for obj in aq_chain(context):
if not IPloneSiteRoot.providedBy(obj):
if IFolderish.providedBy(obj) and not INonStructuralFolder.providedBy(obj):
flag = getattr(obj, "allow_discussion", None)
if flag is not None:
return flag
return None
示例5: is_folderish
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def is_folderish(obj):
"""Should this item be treated as a folder?
Checks isPrincipiaFolderish, as well as the INonStructuralFolder
interfaces.
"""
# If the object explicitly states it doesn't want to be treated as a
# structural folder, don't argue with it.
folderish = bool(getattr(aq_base(obj), 'isPrincipiaFolderish', False))
return folderish and not INonStructuralFolder.providedBy(obj)
示例6: isStructuralFolder
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def isStructuralFolder(self, instance):
context = instance
folderish = bool(getattr(aq_base(context), 'isPrincipiaFolderish',
False))
if not folderish:
return False
elif INonStructuralFolder.providedBy(context):
return False
else:
return folderish
示例7: enabled
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def enabled(self):
uid = self._uid
if uid == CONTENT_UID:
obj = self._pobj
else:
obj = self._query_object(uid)
if obj is not None and obj.isPrincipiaFolderish:
if not INonStructuralFolder.providedBy(obj):
return True
return False
示例8: isStructuralFolder
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def isStructuralFolder(self, obj):
"""Checks if a given object is a "structural folder".
That is, a folderish item which does not explicitly implement
INonStructuralFolder to declare that it doesn't wish to be treated
as a folder by the navtree, the tab generation etc.
"""
return (
obj.isPrincipiaFolderish
and not INonStructuralFolder.providedBy(obj)
)
示例9: is_folderish
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def is_folderish(obj, **kwargs):
"""Should this item be treated as a folder?
Checks isPrincipiaFolderish, as well as the INonStructuralFolder
interfaces.
>>> from Products.CMFPlone.CatalogTool import is_folderish
>>> from Products.CMFPlone.interfaces import INonStructuralFolder
>>> from Products.CMFPlone.interfaces.NonStructuralFolder import INonStructuralFolder as z2INonStructuralFolder
>>> from zope.interface import directlyProvidedBy, directlyProvides
A Folder is folderish generally::
>>> is_folderish(self.folder)
True
But if we make it an INonStructuralFolder it is not::
>>> base_implements = directlyProvidedBy(self.folder)
>>> directlyProvides(self.folder, INonStructuralFolder, directlyProvidedBy(self.folder))
>>> is_folderish(self.folder)
False
Now we revert our interface change and apply the z2 no-folderish interface::
>>> directlyProvides(self.folder, base_implements)
>>> is_folderish(self.folder)
True
>>> z2base_implements = self.folder.__implements__
>>> self.folder.__implements__ = z2base_implements + (z2INonStructuralFolder,)
>>> is_folderish(self.folder)
False
We again revert the interface change and check to make sure that
PrincipiaFolderish is respected::
>>> self.folder.__implements__ = z2base_implements
>>> is_folderish(self.folder)
True
>>> self.folder.isPrincipiaFolderish = False
>>> is_folderish(self.folder)
False
"""
# If the object explicitly states it doesn't want to be treated as a
# structural folder, don't argue with it.
folderish = bool(getattr(aq_base(obj), 'isPrincipiaFolderish', False))
if not folderish:
return False
elif INonStructuralFolder.providedBy(obj):
return False
elif z2INonStructuralFolder.isImplementedBy(obj):
# BBB: for z2 interface compat
return False
else:
return folderish
示例10: getPortlets
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def getPortlets(self, context, position="columnOne"):
mtool = getToolByName(context, "portal_membership")
portlets = []
ids = []
obj = context
if not obj.isPrincipiaFolderish:
obj = aq_parent(aq_inner(obj))
current = obj
allowedTypes = self.getPortletMetatypes()
while mtool.checkPermission("View", current):
folderObjects = current.getFolderContents(full_objects=True, contentFilter={"portal_type": allowedTypes})
for o in folderObjects:
# make sure o is of a proper portal_type
# sometimes the filter doesn't work like with PloneLocalFolderNG
if o.portal_type in allowedTypes:
ids.append(o.id)
if current is obj:
goOn = True
elif o.getShowinsubfolders():
goOn = True
elif hasINonStructuralFolder:
if INonStructuralFolder.providedBy(obj) and current is aq_parent(aq_inner(obj)):
goOn = True
else:
goOn = False
else:
goOn = False
if goOn:
if o.getPosition() == position:
if mtool.checkPermission("View", o):
if not o.id in [p.id for p in portlets]:
portlets.append(o)
if current == obj.portal_url.getPortalObject():
break
else:
# get portlets on higher levels who have showinsubfolders set.
current = aq_parent(aq_inner(current))
# now filter out all objects that have getShow()=0
portlets = [p for p in portlets if p.getShow()]
return portlets
示例11: isStructuralFolder
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def isStructuralFolder(self, obj):
"""Checks if a given object is a "structural folder".
That is, a folderish item which does not explicitly implement
INonStructuralFolder to declare that it doesn't wish to be treated
as a folder by the navtree, the tab generation etc.
>>> ptool = self.portal.plone_utils
>>> ptool.isStructuralFolder(self.folder)
True
"""
if not obj.isPrincipiaFolderish:
return False
elif INonStructuralFolder.providedBy(obj):
return False
else:
return True
示例12: _enabled_for_archetypes
# 需要导入模块: from Products.CMFPlone.interfaces import INonStructuralFolder [as 别名]
# 或者: from Products.CMFPlone.interfaces.INonStructuralFolder import providedBy [as 别名]
def _enabled_for_archetypes(self):
""" Returns True if discussion is enabled for this conversation.
This method checks five different settings in order to figure out if
discussion is enable on a specific content object:
1) Check if discussion is enabled globally in the plone.app.discussion
registry/control panel.
2) If the current content object is a folder, always return
False, since we don't allow comments on a folder. This
setting is used to allow/ disallow comments for all content
objects inside a folder, not for the folder itself.
3) Check if the allow_discussion boolean flag on the content object is
set. If it is set to True or False, return the value. If it set to
None, try further.
4) Traverse to a folder with allow_discussion set to either True or
False. If allow_discussion is not set (None), traverse further until
we reach the PloneSiteRoot.
5) Check if discussion is allowed for the content type.
"""
context = aq_inner(self.context)
# Fetch discussion registry
registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings, check=False)
# Check if discussion is allowed globally
if not settings.globally_enabled:
return False
# Always return False if object is a folder
if IFolderish.providedBy(context) and not INonStructuralFolder.providedBy(context):
return False
def traverse_parents(context):
# Run through the aq_chain of obj and check if discussion is
# enabled in a parent folder.
for obj in aq_chain(context):
if not IPloneSiteRoot.providedBy(obj):
if IFolderish.providedBy(obj) and not INonStructuralFolder.providedBy(obj):
flag = getattr(obj, "allow_discussion", None)
if flag is not None:
return flag
return None
# If discussion is disabled for the object, bail out
obj_flag = getattr(aq_base(context), "allow_discussion", None)
if obj_flag is False:
return False
# Check if traversal returned a folder with discussion_allowed set
# to True or False.
folder_allow_discussion = traverse_parents(context)
if folder_allow_discussion:
if not getattr(self, "allow_discussion", None):
return True
else:
if obj_flag:
return True
# Check if discussion is allowed on the content type
portal_types = getToolByName(self, "portal_types")
document_fti = getattr(portal_types, context.portal_type)
if not document_fti.getProperty("allow_discussion"):
# If discussion is not allowed on the content type,
# check if 'allow discussion' is overridden on the content object.
if not obj_flag:
return False
return True