• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python resolve.resolve函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zope.dottedname.resolve.resolve函数的典型用法代码示例。如果您正苦于以下问题:Python resolve函数的具体用法?Python resolve怎么用?Python resolve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: check_root_site_manager

def check_root_site_manager(tool):
    """2.0.x to 2.1.0 upgrade step checker
    """
    portal = aq_parent(aq_inner(tool))
    try:
        # We have to call setSite to make sure we have a site with a proper
        # acquisition context.
        setSite(portal)
        sm = portal.getSiteManager()
        if sm.utilities.LookupClass != FiveVerifyingAdapterLookup:
            return True
    except ComponentLookupError:
        return True

    for tool_interface in _BAD_UTILITIES:
        try:
            iface = resolve(tool_interface)
        except ImportError:
            continue

        if sm.queryUtility(iface) is not None:
            return True

    for tool_id, tool_interface in _TOOL_UTILITIES:
        tool_obj = getToolByName(portal, tool_id, default=None)
        try:
            iface = resolve(tool_interface)
        except ImportError:
            continue

        if tool_obj is not None and sm.queryUtility(iface) is None:
            return True

    return False
开发者ID:nacho22martin,项目名称:tesis,代码行数:34,代码来源:to21.py


示例2: getProtobuf

    def getProtobuf(self, protobuf_name):
        """
        Get a protobuf class from the identifier supplied.
        """

        # Initialize mapping of protobuf full name to protobuf class
        if self._protobuf_full_name_to_class is None:
            self._protobuf_full_name_to_class = {}
            for contentType in self._content_types.values():
                try:
                    cls = resolve(contentType.python_class)
                    self._protobuf_full_name_to_class[cls.DESCRIPTOR.full_name] = cls
                except ImportError:
                    log.exception('Failed to resolve protobuf: %s', protobuf_name)

        if protobuf_name in self._protobuf_full_name_to_class:
            cls = self._protobuf_full_name_to_class[protobuf_name]
        else:
            try:
                config = self.getContentType(protobuf_name)
            except KeyError:
                raise SchemaException('Could not find protobuf "%s"' % protobuf_name)

            try:
                cls = resolve(config.python_class)
            except ImportError:
                raise ImportError('Could not find protobuf python class "%s"' % config.python_class)

        return cls
开发者ID:jhanson,项目名称:zenoss-protocols,代码行数:29,代码来源:queueschema.py


示例3: setData

    def setData(self, interfacedata, metadata):
        """
        Sets a list of properties on a object.
        Warning: all currently set properties which are not in the
        properties-list wille be removed!

        @param object:      Plone-Object to set the properties on
        @type object:       Plone-Object
        @param properties:  list of propertes.
                            See ftw.publisher.sender.extractor
                            for format details.
        @param type:        list
        @return:            None
        """
        self.logger.info('Updating interface data (UID %s)' %
                (self.object.UID())
        )

        current_ifaces = set(self.adapted.getDirectlyProvidedNames())
        desired_ifaces = set(interfacedata)

        for iface_dotted in current_ifaces - desired_ifaces:
            iface = resolve(iface_dotted)
            noLongerProvides(self.object, iface)

        for iface_dotted in desired_ifaces - current_ifaces:
            iface = resolve(iface_dotted)
            alsoProvides(self.object, iface)
开发者ID:4teamwork,项目名称:ftw.publisher.core,代码行数:28,代码来源:interface_data.py


示例4: register_new_custom_type

def register_new_custom_type(type_key, workflow_key, archetype_key):
    """Retrieve (create if needed) a domain interface and model for type_key,
    and register as new entry on TYPE_REGISTER.
    """
    
    # generate custom domain interface
    domain_iface_name = naming.model_interface_name(type_key)
    try:
        domain_iface = resolve("%s.%s" % (INTERFACE_MODULE.__name__, domain_iface_name))
        log.warn("Custom interface ALREADY EXISTS: %s" % (domain_iface))
    except ImportError:
        domain_iface = new_custom_domain_interface(type_key, domain_iface_name)
    
    # generate custom domain_model
    domain_model_name = naming.model_name(type_key)
    try:
        domain_model = resolve("%s.%s" % (MODEL_MODULE.__name__, domain_model_name))
        log.warn("Custom domain model ALREADY EXISTS: %s" % (domain_model))
    except ImportError:
        domain_model = new_custom_domain_model(type_key, domain_iface, archetype_key)
    
    # type_info entry
    ti = TI(workflow_key, domain_iface, domain_model)
    ti.custom = True
    TYPE_REGISTRY.append((type_key, ti))
    
    log.info("Registered custom type [%s]: %s" % (archetype_key, type_key))
    return type_key, ti
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:28,代码来源:type_info.py


示例5: load_modules

def load_modules(app, config):
    # load up builtins and modules
    app.modules = []

    try:
        _modules = [
            m.strip() for
            m in config['aio']['builtin'].strip('').split('\n')
            if m.strip()]
        for m in _modules:
            app.modules.append(resolve(m))
    except KeyError:
        pass

    try:
        _modules = [
            m.strip() for
            m in config['aio']['modules'].strip('').split('\n')
            if m.strip()]
        for m in _modules:
            app.modules.append(resolve(m))
    except KeyError:
        pass

    app.modules = tuple(app.modules)
开发者ID:phlax,项目名称:aio.app,代码行数:25,代码来源:runner.py


示例6: loadPlugins

    def loadPlugins(self):
        log.err("bit.core.plugins: loadPlugins")

        config = getUtility(IConfiguration)
        plugins = config.get("bit", "plugins")

        snippet = "<include package='zope.component' />"
        zcml = zcml_template % snippet
        xmlconfig(StringIO(zcml))

        if isinstance(plugins, str):
            plugins = [plugins]

        for plugin in plugins:
            snippet = "<include package='%s' />" % plugin
            zcml = zcml_template % snippet
            zcml_path = os.path.join(resolve(plugin).__path__[0], "configure.zcml")
            if os.path.exists(zcml_path):
                xmlconfig(StringIO(zcml))

        for plugin in plugins:
            snippet = "<include package='%s' file='meta.zcml' />" % plugin
            zcml = zcml_template % snippet
            zcml_path = os.path.join(resolve(plugin).__path__[0], "meta.zcml")
            if os.path.exists(zcml_path):
                xmlconfig(StringIO(zcml))

        for plugin in plugins:
            snippet = "<include package='%s' file='plugin.zcml' />" % plugin
            zcml = zcml_template % snippet
            zcml_path = os.path.join(resolve(plugin).__path__[0], "plugin.zcml")
            if os.path.exists(zcml_path):
                xmlconfig(StringIO(zcml))
开发者ID:bithub,项目名称:bit.core,代码行数:33,代码来源:plugins.py


示例7: remove_old_contentleadimage

def remove_old_contentleadimage(context, logger=None):
    if logger is None:
        # Called as upgrade step: define our own logger.
        logger = logging.getLogger('cpskin.policy remove_old_contentleadimage')
    portal = api.portal.get()
    sm = portal.getSiteManager()

    utilities = {
            'subscribers': sm.utilities._subscribers[0],
            'adapters': sm.utilities._adapters[0],
            # 'provided': sm.utilities._provided
            }
    util_klass = resolve('plone.browserlayer.interfaces.ILocalBrowserLayerType')
    reg_klass = resolve('collective.contentleadimage.interfaces.ILeadImageSpecific')
    for sm_type in utilities.keys():
        utility_registrations = utilities[sm_type]
        for x in utility_registrations.keys():
            if x.__module__ == util_klass.__module__ and x == util_klass:
                for name, klass in utility_registrations[x].items():
                    found = find_object_or_class(klass, reg_klass)
                    # if found:
                    #     import pdb; pdb.set_trace()
                    if found:
                        if type(utility_registrations[x][name]) in \
                                [list, tuple, set]:
                            regs = list(utility_registrations[x][name])
                            regs.remove(found)
                            logger.info('{0} {1} removed'.format(sm_type, reg_klass))
                            utility_registrations[x][name] = tuple(regs)
                        else:
                            logger.info('{0} removed'.format(name))
                            del utility_registrations[x][name]

        setattr(sm.utilities, '_' + sm_type, [utility_registrations])
开发者ID:IMIO,项目名称:cpskin.policy,代码行数:34,代码来源:upgrades.py


示例8: load_object

def load_object(epstr):
    """Loads the object represented in entry-point syntax by the
    specified string."""
    if ':' in epstr:
        module, attr = epstr.split(':')
        module = resolve(module)
        return getattr(module, attr)
    return resolve(epstr)
开发者ID:socialplanning,项目名称:topp.utils,代码行数:8,代码来源:eputils.py


示例9: _configure

def _configure(self=None,
               set_up_packages=(),
               features=('devmode', 'testmode'),
               context=None,
               package=None):

    features = set(features) if features is not None else set()

    # This is normally created by a slug, but tests may not always
    # load the slug
    if os.getenv('DATASERVER_DIR_IS_BUILDOUT'): # pragma: no cover
        features.add('in-buildout')


    # zope.component.globalregistry conveniently adds
    # a zope.testing.cleanup.CleanUp to reset the globalSiteManager
    if context is None and (features or package):
        context = config.ConfigurationMachine()
        context.package = package
        xmlconfig.registerCommonDirectives(context)

    for feature in features:
        context.provideFeature(feature)

    if set_up_packages:
        logger.debug("Configuring %s with features %s", set_up_packages, features)

        for i in set_up_packages:
            __traceback_info__ = (i, self)
            if isinstance(i, tuple):
                filename = i[0]
                package = i[1]
            else:
                filename = 'configure.zcml'
                package = i

            if isinstance(package, six.string_types):
                package = dottedname.resolve(package)

            try:
                context = xmlconfig.file(filename, package=package, context=context)
            except IOError as e:
                # Did we pass in a test module (__name__) and there is no
                # configuration in that package? In that case, we want to
                # configure the parent package for sure
                module_path = getattr(package, '__file__', '')
                if (module_path
                        and 'tests' in module_path
                        and os.path.join(os.path.dirname(module_path), filename) == e.filename):
                    parent_package_name = '.'.join(package.__name__.split('.')[:-2])
                    package = dottedname.resolve(parent_package_name)
                    context = xmlconfig.file(filename, package=package, context=context)
                else: # pragma: no cover
                    raise

    return context
开发者ID:NextThought,项目名称:nti.testing,代码行数:56,代码来源:base.py


示例10: unmarshal

 def unmarshal(self, mkey, func_name, marshalled_args, marshalled_kwargs):
     """Does the reverse operation of ``marshal``
     """
     Marshaller = resolve(mkey)
     marshaller = Marshaller()
     func = resolve(func_name)
     args, kwargs = marshaller.unmarshal(
         *marshalled_args,
         **marshalled_kwargs
     )
     return (func, args, kwargs)
开发者ID:ploneintranet,项目名称:ploneintranet.documentviewer,代码行数:11,代码来源:async.py


示例11: __init__

    def __init__(self, logger, data):

        self.input_preparation_list = []
        for plugin_data in data["application_configuration"]["pre_processing"]["plugin_list"]:
            self.input_preparation_list.append(resolve(plugin_data["_class"])(logger, plugin_data))

        self.output_preparation_list = []
        for plugin_data in data["application_configuration"]["post_processing"]["plugin_list"]:
            self.output_preparation_list.append(resolve(plugin_data["_class"])(logger, plugin_data))

        plugin_data = data["application_configuration"]["processing_plugin"]
        self.execution_plugin = resolve(plugin_data["_class"])(logger, plugin_data)
开发者ID:ganeshpardeshi,项目名称:dream,代码行数:12,代码来源:plugin.py


示例12: __init__

  def __init__(self, logger, data):

    self.input_preparation_list = []
    for plugin_data in data['application_configuration']['pre_processing']['plugin_list']:
      self.input_preparation_list.append(resolve(plugin_data['_class'])(logger, plugin_data))

    self.output_preparation_list = []
    for plugin_data in data['application_configuration']['post_processing']['plugin_list']:
      self.output_preparation_list.append(resolve(plugin_data['_class'])(logger, plugin_data))

    plugin_data = data['application_configuration']['processing_plugin']
    self.execution_plugin = resolve(plugin_data['_class'])(logger, plugin_data)
开发者ID:PanosBarlas,项目名称:dream,代码行数:12,代码来源:plugin.py


示例13: sign

 def sign(self, schema, usedottedname=False):
     """
     sign the object with the signature of the schema used on it
     """
     if usedottedname:
         if schema.__module__ != '.'.join((PKGNAME, 'schema.generated')):
             if isdottedname(schema.__identifier__):
                 resolve(schema.__identifier__)  # ensure it can be imported
                 self.signature = schema.__identifier__
                 return
     saver = queryUtility(ISchemaSaver)
     #persist serialization of schema, get signature
     self.signature = saver.add(schema)
开发者ID:upiq,项目名称:uu.dynamicschema,代码行数:13,代码来源:schema.py


示例14: is_operation_valid

 def is_operation_valid(self, registry, operation):
     # Check that the operation exists.
     op_info = registry.get(operation)
     if op_info is None:
         logger.error("Operation %r is not defined.", operation)
         return False
     op_function_name = op_info.get("operation")
     try:
         resolve(op_function_name)
     except ImportError:
         logger.error("ImportError for operation %r: %s", operation, op_function_name)
         return False
     return True
开发者ID:mingtak,项目名称:plone.app.contenttypes_for_tpa,代码行数:13,代码来源:topics.py


示例15: resolve_plugin_class

    def resolve_plugin_class(self, plugin_name):
        try:
            plugin_class = dottedname.resolve(plugin_name)
        except ImportError as e:
            full_plugin_name = 'replay.plugins.' + plugin_name
            try:
                plugin_class = dottedname.resolve(full_plugin_name)
            except ImportError:
                raise e

        if not (inspect.isclass(plugin_class)
                and issubclass(plugin_class, plugins.Plugin)):
            raise ValueError('{} is not a Plugin'.format(plugin_name))

        return plugin_class
开发者ID:e3krisztian,项目名称:replay,代码行数:15,代码来源:context.py


示例16: upgrade_root_site_manager

def upgrade_root_site_manager(tool):
    """2.0.x to 2.1.0 upgrade step handler
    """
    logger = logging.getLogger('GenericSetup.upgrade')
    portal = aq_parent(aq_inner(tool))
    try:
        setSite(portal)
        sm = portal.getSiteManager()
        if sm.utilities.LookupClass != FiveVerifyingAdapterLookup:
            sm.__parent__ = aq_base(portal)
            sm.utilities.LookupClass = FiveVerifyingAdapterLookup
            sm.utilities._createLookup()
            sm.utilities.__parent__ = sm
            logger.info('LookupClass replaced.')
        else:
            for tool_interface in _BAD_UTILITIES:
                try:
                    iface = resolve(tool_interface)
                except ImportError:
                    continue

                if sm.queryUtility(iface) is not None:
                    sm.unregisterUtility(provided=iface)
                    logger.info('Unregistered utility for %s' % tool_interface)

            for tool_id, tool_interface in _TOOL_UTILITIES:
                tool_obj = getToolByName(portal, tool_id, default=None)
                try:
                    iface = resolve(tool_interface)
                except ImportError:
                    continue

                if tool_obj is not None and sm.queryUtility(iface) is None:
                    sm.registerUtility(tool_obj, iface)
                    logger.info('Registered %s for interface %s' % (
                                                      tool_id, tool_interface))
            return
    except ComponentLookupError:
        next = find_next_sitemanager(portal)
        if next is None:
            next = base
        name = '/'.join(portal.getPhysicalPath())
        sm = PersistentComponents(name, (next,))
        sm.__parent__ = aq_base(portal)
        portal.setSiteManager(sm)
        logger.info("Site manager '%s' added." % name)
    getMultiAdapter((sm, SetupEnviron()), IBody).body = _COMPONENTS_XML
    logger.info('Utility registrations added.')
开发者ID:nacho22martin,项目名称:tesis,代码行数:48,代码来源:to21.py


示例17: __get__

 def __get__(self, inst, cls=None):
     global generated
     if inst is None:
         return getObjectSpecification(cls)
     spec = getattr(inst, '__provides__', None)
     if spec is None:
         spec = implementedBy(cls)
     signature = getattr(inst, 'signature', None)
     if signature is None:
         return spec
     if not ismd5hex(signature):
         if not isdottedname(signature):
             return spec
         # not an md5 signature, so perhaps we have a dotted name
         try:
             iface = resolve(signature)
             if not IInterface.providedBy(iface):
                 raise ValueError('Not interface: %s' % signature)
             return Implements(iface, spec)
         except ImportError:
             logger.warning('SignatureAwareDescriptor: '
                            'unabled to resolve interface '
                            '%s by dotted name.')
             return spec
     iface_name = 'I%s' % signature
     dynamic = [getattr(generated, iface_name)]
     dynamic.append(spec)
     spec = Implements(*dynamic)
     return spec
开发者ID:upiq,项目名称:uu.dynamicschema,代码行数:29,代码来源:schema.py


示例18: includableInfo

    def includableInfo(self, zcml_to_look_for, result,
                       seen=None, exclude=(), extras=()):
        if seen is None:
            seen = set()

        seen.add(self.context.project_name)

        self.includeReqs(self.context.requires(), zcml_to_look_for, result, seen, exclude)

        for dotted_name in self.dottedNames():
            module = resolve(dotted_name)
            for candidate in zcml_to_look_for:
                candidate_path = os.path.join(
                    os.path.dirname(module.__file__), candidate)
                if os.path.isfile(candidate_path):
                    if dotted_name not in result[candidate]:
                        result[candidate].append(dotted_name)

        for extra in extras:
            seen.add((self.context.project_name, extra))

            try:
                reqs = self.context.requires(extras=(extra,))
            except UnknownExtra:
                return

            if reqs:
                self.includeReqs(reqs, zcml_to_look_for, result, seen, exclude)
开发者ID:Zojax,项目名称:zojax.autoinclude,代码行数:28,代码来源:zcml.py


示例19: domain_container

 def domain_container( self ):
     if self._container_class:
        return self._container_class
     container_class= resolve( self.container )
     self._container_class = type( "ManagedContainer", ( _ManagedContainer, container_class), dict( container_class.__dict__) )        
     protectLikeUnto( self._container_class, container_class )
     return self._container_class
开发者ID:kapilt,项目名称:zope-alchemist,代码行数:7,代码来源:managed.py


示例20: onDiscovery

    def onDiscovery(self, theme, settings, dependenciesSettings):
        res = queryResourceDirectory(THEME_RESOURCE_NAME, theme)
        if res is None:
            return

        directoryName = 'overrides'
        if 'directory' in settings:
            directoryName = settings['directory']

        if res.isDirectory(directoryName):

            layer = getattr(schemata, theme, None)

            if 'layer' in settings:
                layerName = settings['layer']

                try:
                    layer = resolve(layerName)
                except (ImportError, AttributeError,):
                    logger.warn("Could not import %s" % layerName)
                    return

            path = os.path.join(res.directory, directoryName)

            manager = z3c.jbot.metaconfigure.handler(path, layer)
            self.registered[theme] = manager
开发者ID:djowett,项目名称:plone.app.themingplugins,代码行数:26,代码来源:plugin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python interfaces.IDCDescriptiveProperties类代码示例发布时间:2022-05-26
下一篇:
Python deprecation.deprecated函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap