当前位置: 首页>>代码示例>>Python>>正文


Python IDexterityFTI.providedBy方法代码示例

本文整理汇总了Python中plone.dexterity.interfaces.IDexterityFTI.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python IDexterityFTI.providedBy方法的具体用法?Python IDexterityFTI.providedBy怎么用?Python IDexterityFTI.providedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plone.dexterity.interfaces.IDexterityFTI的用法示例。


在下文中一共展示了IDexterityFTI.providedBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remove_versioning_behavior

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
 def remove_versioning_behavior(self, fti):
     if not IDexterityFTI.providedBy(fti):
         return
     behaviors = list(fti.behaviors)
     if self.behavior_name in behaviors:
         behaviors.remove(self.behavior_name)
         fti.behaviors = behaviors
开发者ID:staeff,项目名称:Products.CMFPlone,代码行数:9,代码来源:types.py

示例2: installTypeIfNeeded

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
def installTypeIfNeeded(type_name):
    """Make sure the dexterity-fti is already installed.
    If not we create a empty dexterity fti and load the
    information from the fti in the profile.
    """
    if type_name not in DEFAULT_TYPES:
        raise KeyError('{0} is not one of the default types'.format(type_name))
    portal = getSite()
    tt = getToolByName(portal, 'portal_types')
    fti = tt.getTypeInfo(type_name)
    if IDexterityFTI.providedBy(fti):
        # The dx-type is already installed, so keep it.  But this
        # might be an old dexterity type of Collection, in which case
        # it is better to replace it.
        if type_name != 'Collection':
            return
        if fti.klass == 'plone.app.contenttypes.content.Collection':
            # If the klass is fine, we are happy.
            return
    if fti:
        tt.manage_delObjects(type_name)
    tt.manage_addTypeInformation('Dexterity FTI', id=type_name)
    dx_fti = tt.getTypeInfo(type_name)
    ps = getToolByName(portal, 'portal_setup')
    profile_info = ps.getProfileInfo('profile-plone.app.contenttypes:default')
    profile_path = os.path.join(profile_info['path'])
    environ = DirectoryImportContext(ps, profile_path)
    parent_path = 'types/'
    importObjects(dx_fti, parent_path, environ)
开发者ID:enfold,项目名称:plone.app.contenttypes,代码行数:31,代码来源:utils.py

示例3: invalidate

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
 def invalidate(self, fti):
     if fti is not None and not IDexterityFTI.providedBy(fti):
         # fti is a name, lookup
         fti = queryUtility(IDexterityFTI, name=fti)
     if fti is not None:
         invalidate_cache(fti)
         self.invalidations += 1
开发者ID:plone,项目名称:plone.dexterity,代码行数:9,代码来源:schema.py

示例4: add_versioning_behavior

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
 def add_versioning_behavior(self, fti):
     if not IDexterityFTI.providedBy(fti):
         return
     behaviors = list(fti.behaviors)
     if self.behavior_name not in behaviors:
         behaviors.append(self.behavior_name)
         fti.behaviors = behaviors
开发者ID:staeff,项目名称:Products.CMFPlone,代码行数:9,代码来源:types.py

示例5: __call__

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
    def __call__(self):
        req = self.request
        if req.REQUEST_METHOD != 'POST':
            return
        filedata = self.request.form.get("file", None)
        if filedata is None:
            return
        filename = filedata.filename
        content_type = mimetypes.guess_type(filename)[0] or ""

        if not filedata:
            return

        # Determine if the default file/image types are DX or AT based
        ctr = getToolByName(self.context, 'content_type_registry')
        type_ = ctr.findTypeName(filename.lower(), '', '') or 'File'

        DX_BASED = False
        if HAS_DEXTERITY:
            pt = getToolByName(self.context, 'portal_types')
            if IDexterityFTI.providedBy(getattr(pt, type_)):
                factory = IDXFileFactory(self.context)
                DX_BASED = True
            else:
                factory = IATCTFileFactory(self.context)
        else:
            factory = IATCTFileFactory(self.context)

        obj = factory(filename, content_type, filedata)

        if DX_BASED:
            if 'File' in obj.portal_type:
                size = obj.file.getSize()
                content_type = obj.file.contentType
            elif 'Image' in obj.portal_type:
                size = obj.image.getSize()
                content_type = obj.image.contentType

            result = {
                "type": content_type,
                "size": size
            }
        else:
            try:
                size = obj.getSize()
            except AttributeError:
                size = obj.getObjSize()

            result = {
                "type": obj.getContentType(),
                "size": size
            }

        result.update({
            'url': obj.absolute_url(),
            'name': obj.getId(),
            'uid': IUUID(obj),
            'filename': filename
        })
        return json.dumps(result)
开发者ID:darrylhebbes,项目名称:plone.app.widgets,代码行数:62,代码来源:browser.py

示例6: __call__

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
    def __call__(self, context):
        context = getattr(context, 'context', context)
        portal = getToolByName(context, 'portal_url').getPortalObject()
        items = [SimpleTerm('auto', 'auto', context.translate(_('label_default_portaltype_configuration',
                                                      default=u'Default configuration (Content Type Registry).')))]
        archetype_tool = getToolByName(context, 'archetype_tool', None)
        if archetype_tool:
            flt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IFileContent)]
            ilt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IImageContent)]
            items.extend([SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
                      for t in flt])
            file_types = [t['portal_type'] for t in flt]
            items.extend([SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
                      for t in ilt if t['portal_type'] not in file_types])

        for fti in portal.portal_types.objectValues():
            if HAS_DEXTERITY and IDexterityFTI.providedBy(fti):
                try:
                    schema = fti.lookupSchema()
                except ImportError:
                    # this dexterity type was changed/removed in an improper way
                    # no need to punish, just fail gracefully
                    continue
                fields = getFieldsInOrder(schema)
                for fieldname, field in fields:
                    if INamedFileField.providedBy(field) or INamedImageField.providedBy(field):
                        items.append(SimpleTerm(fti.getId(), fti.getId(), fti.Title()))
                        break

        return SimpleVocabulary(items)
开发者ID:eleddy,项目名称:collective.quickupload,代码行数:32,代码来源:vocabularies.py

示例7: test_install_dx_type_if_needed

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
 def test_install_dx_type_if_needed(self):
     from plone.app.contenttypes.migration.utils import installTypeIfNeeded
     tt = self.portal.portal_types
     tt.manage_delObjects('Document')
     tt.manage_addTypeInformation(
         'Factory-based Type Information with dynamic views',
         id='Document')
     applyProfile(
         self.portal,
         'plone.app.contenttypes:default',
         blacklisted_steps=['typeinfo'])
     fti = tt.getTypeInfo('Document')
     self.assertFalse(IDexterityFTI.providedBy(fti))
     installTypeIfNeeded('Document')
     fti = tt.getTypeInfo('Document')
     self.assertTrue(IDexterityFTI.providedBy(fti))
开发者ID:enfold,项目名称:plone.app.contenttypes,代码行数:18,代码来源:test_migration_browser.py

示例8: fix_core_behaviors_in_ftis

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
def fix_core_behaviors_in_ftis(context):
    # The behaviors for IRichText and ILeadImage have been renamed.
    # All FTIs that use them must be updated accordingly
    # See plone/plone.app.contenttypes#480
    types_tool = getToolByName(context, 'portal_types')
    to_replace = {
        'plone.app.contenttypes.behaviors.richtext.IRichText':
            'plone.app.contenttypes.behaviors.richtext.IRichTextBehavior',
        'plone.app.contenttypes.behaviors.leadimage.ILeadImage':
            'plone.app.contenttypes.behaviors.leadimage.ILeadImageBehavior',
    }
    ftis = types_tool.listTypeInfo()
    for fti in ftis:
        # Since we're handling dexterity behaviors, we only care about
        # dexterity FTIs
        if not IDexterityFTI.providedBy(fti):
            continue
        behaviors = []
        change_needed = False
        for behavior in fti.behaviors:
            if behavior in to_replace:
                behavior = to_replace[behavior]
                change_needed = True
            behaviors.append(behavior)
        if change_needed:
            fti.behaviors = tuple(behaviors)
开发者ID:plone,项目名称:plone.app.upgrade,代码行数:28,代码来源:alphas.py

示例9: removeBehaviors

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
def removeBehaviors(context):
    """Remove p.a.multilingual behaviors from p.a.contenttypes types."""

    if context.readDataFile('plone.app.multilingual_uninstall.txt') is None:
        return

    portal = context.getSite()
    portal_types = getToolByName(portal, 'portal_types')

    behavior = 'plone.app.multilingual.dx.interfaces.IDexterityTranslatable'
    # plone.app.contenttype types
    typeNames = [
        'Document',
        'File',
        'Folder',
        'Image',
        'Link',
        'News Item',
    ]
    for name in typeNames:
        type_ = portal_types.get(name)

        # safety first
        if not type_ or not IDexterityFTI.providedBy(type_):
            continue

        behaviors = list(type_.behaviors)
        behaviors.remove(behavior)
        type_.behaviors = tuple(behaviors)
开发者ID:fredvd,项目名称:plone.app.multilingual,代码行数:31,代码来源:setuphandlers.py

示例10: __call__

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
    def __call__(self, context):
        context = getattr(context, 'context', context)
        portal = getToolByName(context, 'portal_url').getPortalObject()
        flt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IFileContent)]
        ilt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IImageContent)]

        items = [SimpleTerm('auto', 'auto', context.translate('label_default_portaltype_configuration',
                                                      default=u'Default configuration (Content Type Registry).',
                                                      domain='collective.quickupload')),]
        all_portal_types = []
        for t in flt+ilt:
            portal_type = t['portal_type']
            if portal_type not in all_portal_types:
                items.append(SimpleTerm(portal_type, portal_type, t['type_ui_info']))
                all_portal_types.append(portal_type)
            
        for fti in portal.portal_types.objectValues():
            if HAS_DEXTERITY and IDexterityFTI.providedBy(fti):
                fields = getFieldsInOrder(fti.lookupSchema())
                for fieldname, field in fields:
                    if INamedFileField.providedBy(field) or INamedImageField.providedBy(field):
                        items.append(SimpleTerm(fti.getId(), fti.getId(), fti.Title()))
                        break

        return SimpleVocabulary(items)
开发者ID:redomino,项目名称:collective.quickupload,代码行数:27,代码来源:vocabularies.py

示例11: remove_versioning_behavior

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
 def remove_versioning_behavior(self, fti):
     if not IDexterityFTI.providedBy(fti):
         return
     behaviors = list(fti.behaviors)
     if self.behavior_name in behaviors:
         behaviors.remove(self.behavior_name)
     # TODO: remove locking if it wasn't set in first place
     fti.behaviors = behaviors
开发者ID:adam139,项目名称:Products.CMFPlone,代码行数:10,代码来源:types.py

示例12: ftiAdded

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
def ftiAdded(object, event):
    """When the FTI is created, install local components
    """

    if not IDexterityFTI.providedBy(event.object):
        return

    register(event.object)
开发者ID:adam139,项目名称:plone.dexterity,代码行数:10,代码来源:fti.py

示例13: ftiRemoved

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
def ftiRemoved(object, event):
    """When the FTI is removed, uninstall local coponents
    """

    if not IDexterityFTI.providedBy(event.object):
        return

    unregister(event.object)
开发者ID:adam139,项目名称:plone.dexterity,代码行数:10,代码来源:fti.py

示例14: ftiModified

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
def ftiModified(object, event):
    """When an FTI is modified, re-sync and invalidate the schema, if
    necessary.
    """

    if not IDexterityFTI.providedBy(event.object):
        return

    fti = event.object
    portal_type = fti.getId()

    mod = {}
    for desc in event.descriptions:
        if IDexterityFTIModificationDescription.providedBy(desc):
            mod[desc.attribute] = desc.oldValue

    # If the factory utility name was modified, we may get an orphan if one
    # was registered as a local utility to begin with. If so, remove the
    # orphan.

    if 'factory' in mod:
        old_factory = mod['factory']

        site = getUtility(ISiteRoot)
        site_manager = getSiteManager(site)

        # Remove previously registered factory, if no other type uses it.
        unregister_factory(old_factory, site_manager)

        # Register a new local factory if one doesn't exist already
        new_factory_utility = queryUtility(IFactory, name=fti.factory)
        if new_factory_utility is None:
            site_manager.registerUtility(
                DexterityFactory(portal_type),
                IFactory,
                fti.factory,
                info='plone.dexterity.dynamic'
            )

    # Determine if we need to invalidate the schema at all
    if 'behaviors' in mod \
       or 'schema' in mod \
       or 'model_source' in mod \
       or 'model_file' in mod \
       or 'schema_policy' in mod:

        # Determine if we need to re-sync a dynamic schema
        if (fti.model_source or fti.model_file) \
           and ('model_source' in mod or 'model_file' in mod or 'schema_policy' in mod):

            schemaName = portalTypeToSchemaName(portal_type)
            schema = getattr(plone.dexterity.schema.generated, schemaName)

            model = fti.lookupModel()
            sync_bases = 'schema_policy' in mod
            syncSchema(model.schema, schema, overwrite=True, sync_bases=sync_bases)

        notify(SchemaInvalidatedEvent(portal_type))
开发者ID:adam139,项目名称:plone.dexterity,代码行数:60,代码来源:fti.py

示例15: getDexterityTypes

# 需要导入模块: from plone.dexterity.interfaces import IDexterityFTI [as 别名]
# 或者: from plone.dexterity.interfaces.IDexterityFTI import providedBy [as 别名]
 def getDexterityTypes(self):
     """
     Returns a list of Dexterity FTIs.
     """
     
     portal_types = getToolByName(self.context, 'portal_types')
     for fti in portal_types.listTypeInfo():
         if IDexterityFTI.providedBy(fti):
             yield fti
开发者ID:Groundwire,项目名称:collective.salesforce.content,代码行数:11,代码来源:sync.py


注:本文中的plone.dexterity.interfaces.IDexterityFTI.providedBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。