本文整理汇总了Python中plone.behavior.interfaces.IBehaviorAssignable.supports方法的典型用法代码示例。如果您正苦于以下问题:Python IBehaviorAssignable.supports方法的具体用法?Python IBehaviorAssignable.supports怎么用?Python IBehaviorAssignable.supports使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.behavior.interfaces.IBehaviorAssignable
的用法示例。
在下文中一共展示了IBehaviorAssignable.supports方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dx_feed_indexer
# 需要导入模块: from plone.behavior.interfaces import IBehaviorAssignable [as 别名]
# 或者: from plone.behavior.interfaces.IBehaviorAssignable import supports [as 别名]
def dx_feed_indexer(context):
assignable = IBehaviorAssignable(context, None)
if assignable is not None:
if assignable.supports(IFeedControl):
try:
return tuple(context.feeds)
except TypeError:
return tuple()
示例2: dx_schedule_indexer
# 需要导入模块: from plone.behavior.interfaces import IBehaviorAssignable [as 别名]
# 或者: from plone.behavior.interfaces.IBehaviorAssignable import supports [as 别名]
def dx_schedule_indexer(context):
assignable = IBehaviorAssignable(context, None)
if assignable is None or not assignable.supports(IFeedControl):
return
date = getattr(context, "feedSchedule", None)
if date is None:
assignable = IBehaviorAssignable(context, None)
if assignable is not None:
if assignable.supports(IDublinCore):
return context.effective_date
return DateTime(
date.year,
date.month,
date.day
)
示例3: test_member_behaviors
# 需要导入模块: from plone.behavior.interfaces import IBehaviorAssignable [as 别名]
# 或者: from plone.behavior.interfaces.IBehaviorAssignable import supports [as 别名]
def test_member_behaviors(self):
behaviors = [INameFromFullName, IReferenceable,
metadata.ICategorization, metadata.IPublication,
metadata.IOwnership, IMembraneUser, IProvidePasswords]
member = self._createType(
self.layer['portal'], 'dexterity.membrane.member', 'les')
assignable = IBehaviorAssignable(member)
for b in behaviors:
self.assertTrue(assignable.supports(b),
"member type should support %s behavior" % b)
示例4: test_member_behavior_blacklist
# 需要导入模块: from plone.behavior.interfaces import IBehaviorAssignable [as 别名]
# 或者: from plone.behavior.interfaces.IBehaviorAssignable import supports [as 别名]
def test_member_behavior_blacklist(self):
# Some behaviors should definitely NOT be provided.
black_list = [metadata.IDublinCore, metadata.IBasic]
# Note that we would want INameFromTitle in the black list as
# well, but it cannot be, as it gets pulled in as base class
# of INameFromFullName.
member = self._createType(self.layer["portal"], "dexterity.membrane.organizationmember", "les")
assignable = IBehaviorAssignable(member)
for b in black_list:
self.assertFalse(assignable.supports(b), "member type should NOT support %s behavior" % b)
示例5: __call__
# 需要导入模块: from plone.behavior.interfaces import IBehaviorAssignable [as 别名]
# 或者: from plone.behavior.interfaces.IBehaviorAssignable import supports [as 别名]
def __call__(self, context):
assignable = IBehaviorAssignable(context, None)
if assignable is None:
return None
if not assignable.supports(self.behavior.interface):
return None
if self.behavior.factory is not None:
adapted = self.behavior.factory(context)
else:
# When no factory is specified the object should provide the
# behavior directly
adapted = context
return adapted
示例6: test_has_behavior
# 需要导入模块: from plone.behavior.interfaces import IBehaviorAssignable [as 别名]
# 或者: from plone.behavior.interfaces.IBehaviorAssignable import supports [as 别名]
def test_has_behavior(self):
""" Test behavior and assignable works nicely.
"""
self.loginAsPortalOwner()
self.portal.invokeFactory("Document", "doc")
doc = self.portal.doc
# Check assignable works
from plone.behavior.interfaces import IBehaviorAssignable
assignable = IBehaviorAssignable(doc, None)
self.assertTrue(assignable.supports(IMobileBehavior))
self.assertNotEqual(assignable, None)
# Check behavior works
self.assertTrue(IMobileContentish.providedBy(doc))
behavior = IMobileBehavior(doc)
self.assertNotEquals(behavior, None)
示例7: make_some_evil_site_content
# 需要导入模块: from plone.behavior.interfaces import IBehaviorAssignable [as 别名]
# 或者: from plone.behavior.interfaces.IBehaviorAssignable import supports [as 别名]
def make_some_evil_site_content(self):
""" Test behavior and assignable works nicely.
"""
self.loginAsPortalOwner()
self.portal.invokeFactory("Document", "doc")
doc = self.portal.doc
doc.processForm()
# Check assignable works
from plone.behavior.interfaces import IBehaviorAssignable
assignable = IBehaviorAssignable(doc, None)
self.assertTrue(assignable.supports(IMultiChannelBehavior))
self.assertNotEqual(assignable, None)
# Check behavior works
self.assertTrue(IMobileContentish.providedBy(doc))
behavior = IMultiChannelBehavior(doc)
behavior.contentMedias = ContentMediaOption.BOTH
behavior.save()
示例8: dx_category_indexer
# 需要导入模块: from plone.behavior.interfaces import IBehaviorAssignable [as 别名]
# 或者: from plone.behavior.interfaces.IBehaviorAssignable import supports [as 别名]
def dx_category_indexer(context):
assignable = IBehaviorAssignable(context, None)
if assignable is not None:
if assignable.supports(IFeedControl):
return getattr(context, "feedCategory", None)