本文整理汇总了Python中Products.Archetypes.interfaces.referenceable.IReferenceable.isImplementedByInstancesOf方法的典型用法代码示例。如果您正苦于以下问题:Python IReferenceable.isImplementedByInstancesOf方法的具体用法?Python IReferenceable.isImplementedByInstancesOf怎么用?Python IReferenceable.isImplementedByInstancesOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.Archetypes.interfaces.referenceable.IReferenceable
的用法示例。
在下文中一共展示了IReferenceable.isImplementedByInstancesOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _listTypeInfo
# 需要导入模块: from Products.Archetypes.interfaces.referenceable import IReferenceable [as 别名]
# 或者: from Products.Archetypes.interfaces.referenceable.IReferenceable import isImplementedByInstancesOf [as 别名]
def _listTypeInfo(self):
""" List the portal types which are available.
"""
pt = getToolByName(self, "portal_types", None)
at = getToolByName(self, "archetype_tool", None)
if (pt is None) or (at is None):
return ()
else:
meta_types = [
ty["meta_type"]
for ty in at.listRegisteredTypes()
if IReferenceable.isImplementedByInstancesOf(ty["klass"])
]
tis = [t for t in pt.objectValues() if t.content_meta_type in meta_types]
tis.sort(lambda a, b: cmp(a.Title(), b.Title()))
return tis
示例2: modify_fti
# 需要导入模块: from Products.Archetypes.interfaces.referenceable import IReferenceable [as 别名]
# 或者: from Products.Archetypes.interfaces.referenceable.IReferenceable import isImplementedByInstancesOf [as 别名]
def modify_fti(fti, klass, pkg_name):
fti[0]['id'] = klass.__name__
fti[0]['meta_type'] = klass.meta_type
fti[0]['description'] = klass.__doc__
fti[0]['factory'] = 'add%s' % klass.__name__
fti[0]['product'] = pkg_name
if hasattr(klass, 'content_icon'):
fti[0]['content_icon'] = klass.content_icon
if hasattr(klass, 'global_allow'):
fti[0]['global_allow'] = klass.global_allow
if hasattr(klass, 'allow_discussion'):
fti[0]['allow_discussion'] = klass.allow_discussion
if hasattr(klass, 'allowed_content_types'):
allowed = klass.allowed_content_types
fti[0]['allowed_content_types'] = allowed
fti[0]['filter_content_types'] = allowed and True or False
if hasattr(klass, 'filter_content_types'):
fti[0]['filter_content_types'] = klass.filter_content_types
if hasattr(klass, 'immediate_view'):
fti[0]['immediate_view'] = klass.immediate_view
if not IReferenceable.isImplementedByInstancesOf(klass):
refs = findDict(fti[0]['actions'], 'id', 'references')
refs['visible'] = False
if not IExtensibleMetadata.isImplementedByInstancesOf(klass):
refs = findDict(fti[0]['actions'], 'id', 'metadata')
refs['visible'] = False
# Set folder_listing to 'view' if the class implements ITemplateMixin
if not ITemplateMixin.isImplementedByInstancesOf(klass):
actions = []
for action in fti[0]['actions']:
if action['id'] != 'folderlisting':
actions.append(action)
else:
action['action'] = 'string:${folder_url}/view'
actions.append(action)
fti[0]['actions'] = tuple(actions)
# Remove folderlisting action from non folderish content types
if not getattr(klass,'isPrincipiaFolderish', None):
actions = []
for action in fti[0]['actions']:
if action['id'] != 'folderlisting':
actions.append(action)
fti[0]['actions'] = tuple(actions)
# CMF 1.5 method aliases
if getattr(klass, 'aliases', None):
aliases = klass.aliases
if not isinstance(aliases, dict):
raise TypeError, "Invalid type for method aliases in class %s" % klass
for required in ('(Default)', 'view',):
if required not in aliases:
raise ValueError, "Alias %s is required but not provied by %s" % (
required, klass)
fti[0]['aliases'] = aliases
# Dynamic View FTI support
if getattr(klass, 'default_view', False):
default_view = klass.default_view
if not isinstance(default_view, basestring):
raise TypeError, "Invalid type for default view in class %s" % klass
fti[0]['default_view'] = default_view
fti[0]['view_methods'] = (default_view, )
if getattr(klass, 'suppl_views', False):
suppl_views = klass.suppl_views
if not isinstance(suppl_views, (list, tuple)):
raise TypeError, "Invalid type for suppl views in class %s" % klass
if not default_view in suppl_views:
suppl_views = suppl_views + (default_view, )
fti[0]['view_methods'] = suppl_views
if getattr(klass, '_at_fti_meta_type', False):
fti[0]['fti_meta_type'] = klass._at_fti_meta_type
else:
if fti[0].get('fti_meta_type', False):
klass._at_fti_meta_type = fti[0]['fti_meta_type']
else:
fti[0]['fti_meta_type'] = FactoryTypeInformation.meta_type