本文整理汇总了Python中OFS.interfaces.IOrderedContainer类的典型用法代码示例。如果您正苦于以下问题:Python IOrderedContainer类的具体用法?Python IOrderedContainer怎么用?Python IOrderedContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IOrderedContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_position_in_parent
def _get_position_in_parent(obj):
# Use IOrderedContainer interface to extract the object's manual ordering position
parent = obj.aq_inner.aq_parent
ordered = IOrderedContainer(parent, None)
if ordered is not None:
return ordered.getObjectPosition(obj.getId())
return 0
示例2: revertOrder
def revertOrder(obj, eve):
"""
Use IOrderedContainer interface to move an object to top of folder on creation.
"""
parent = obj.aq_inner.aq_parent
ordered = IOrderedContainer(parent, None)
if ordered is not None:
ordered.moveObjectToPosition(obj.getId(), 0)
示例3: getObjPositionInParent
def getObjPositionInParent(obj):
""" Helper method for catalog based folder contents.
"""
parent = aq_parent(aq_inner(obj))
ordered = IOrderedContainer(parent, None)
if ordered is not None:
return ordered.getObjectPosition(obj.getId())
return 0
示例4: _getPositionInParent
def _getPositionInParent(obj):
parent = aq_parent(aq_inner(obj))
ordered = IOrderedContainer(parent, None)
if ordered is not None:
pos = ordered.getObjectPosition(obj.getId())
else:
pos = 0
return pos
示例5: getObjPositionInParent
def getObjPositionInParent(obj):
""" Helper method for catalog based folder contents.
>>> from Products.CMFPlone.CatalogTool import getObjPositionInParent
>>> getObjPositionInParent(self.folder)
0
"""
parent = aq_parent(aq_inner(obj))
ordered = IOrderedContainer(parent, None)
if ordered is not None:
return ordered.getObjectPosition(obj.getId())
return 0
示例6: __init__
def __init__(self, context):
self.context = context
self.mship = getToolByName(self.context, 'portal_membership')
self.sort = IOrderedContainer.providedBy(self.context) and self.mship.checkPermission(permissions.ModifyPortalContent, self.context)
self.sort_url = '%s/article_moveitem?anchor=%%s&delta=%%s&item_id=%%s' % self.context.absolute_url()
self.show_hide_url = '%s/@@article_showhideitem?anchor=%%s&action=%%s&uid=%%s&component=%%s' % self.context.absolute_url()
self.delete = self.mship.checkPermission(permissions.DeleteObjects, self.context)
示例7: __init__
def __init__(self, context):
self.pos = []
self.component = ''
self.context = context
self.mship = getToolByName(self.context, 'portal_membership')
self.delete = self.mship.checkPermission(permissions.DeleteObjects, self.context) or False
self.sort = (IOrderedContainer.providedBy(self.context)
and self.mship.checkPermission(permissions.ModifyPortalContent, self.context)) or False
示例8: __call__
def __call__(self, config):
parent = aq_parent(aq_inner(self.context))
klass = self.context.__class__
owner = self.context.getOwner()
data = {'_classname': klass.__name__,
'_class': klass.__module__ + '.' + klass.__name__,
'_id': self.context.getId(),
'_owner': owner and owner.getId(),
'_path': '/'.join(self.context.getPhysicalPath()),
'_type': self.context.portal_type}
ordered_parent = IOrderedContainer(parent, None)
if ordered_parent:
data['_obj_position_in_parent'] = ordered_parent.getObjectPosition(
self.context.getId())
return data
示例9: _extractObjects
def _extractObjects(self):
fragment = self._doc.createDocumentFragment()
objects = self.context.objectValues()
if not IOrderedContainer.providedBy(self.context):
objects = list(objects)
objects.sort(lambda x,y: cmp(x.getId(), y.getId()))
for obj in objects:
exporter = queryMultiAdapter((obj, self.environ), INode)
if exporter:
fragment.appendChild(exporter.node)
return fragment
示例10: getOrdering
def getOrdering(self):
if IPloneSiteRoot.providedBy(self.context):
return self.context
try:
ordering = self.context.aq_base.getOrdering()
except AttributeError:
if IOrderedContainer.providedBy(self.context):
# Archetype
return IOrderedContainer(self.context)
return None
if not IExplicitOrdering.providedBy(ordering):
return None
return ordering
示例11: orderable
def orderable(self):
"""
"""
if self.is_special_type():
return True
iface = IOrderedContainer.providedBy(aq_inner(self.context))
attr = self.context.aq_explicit\
.get('sortAttribute', '') == 'getObjPositionInParent'
if self.contentFilter.get('sort_on', '') != 'getObjPositionInParent':
return False
return iface and attr
示例12: _copyPortalAttributes
def _copyPortalAttributes(self, peer):
peer.portal_type = self.context.portal_type
peer.content_uid = self.context.UID()
peer.id = self.context.id
peer.path = '/'.join(self.context.getPhysicalPath())
portal_url = getattr(self.context, 'portal_url', None)
if portal_url:
peer.relative_path = "/".join(
portal_url.getRelativeContentPath(self.context))
wf_tool = getattr(self.context, 'portal_workflow', None)
if wf_tool is None:
return
peer.status = wf_tool.getCatalogVariablesFor(
self.context).get('review_state')
container = self.context.getParentNode()
if not IOrderedContainer.providedBy(container):
return
peer.folder_position = container.getObjectPosition(
self.context.getId())
示例13: test_implementsOrderInterface
def test_implementsOrderInterface(self):
self.failUnless(OFSIOrderedContainer.providedBy(self._ATCT))
self.failUnless(IZopeOrderedContainer.isImplementedBy(self._ATCT))
self.failUnless(IOrderedContainer.isImplementedBy(self._ATCT))
self.failUnless(verifyObject(IZopeOrderedContainer, self._ATCT))
self.failUnless(verifyObject(IOrderedContainer, self._ATCT))
示例14: test_ordered_container_interface
def test_ordered_container_interface(self):
"""Verify the OrderedContainer interface being used."""
self.assertTrue(IOrderedContainer.providedBy(self.folder))
示例15: get_position_in_parent
def get_position_in_parent(obj):
parent = obj.aq_inner.aq_parent
ordered = IOrderedContainer(parent, None)
if ordered is not None:
return ordered.getObjectPosition(obj.getId())
return 0