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

Python util.qual函数代码示例

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

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



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

示例1: test_handlerWithIdentifier

    def test_handlerWithIdentifier(self):
        gatherer = LiveGatherer()
        ctx = context.WovenContext()
        ctx.remember(gatherer, livepage.IClientHandle)

        oneQual = util.qual(oneHandler)
        twoQual = util.qual(twoHandler)

        ## Subscribe both handlers to the same identifier
        livepage.handler(oneHandler, identifier="same")(ctx, None)
        livepage.handler(twoHandler, identifier="same")(ctx, None)

        gatherer.handleInput("same")

        self.assertEquals(gatherer.heard, ["one", "two"])
开发者ID:RichDijk,项目名称:eXe,代码行数:15,代码来源:test_livepage.py


示例2: getComponent

    def getComponent(self, interface, registry=None, default=None):
        """Create or retrieve an adapter for the given interface.

        If such an adapter has already been created, retrieve it from the cache
        that this instance keeps of all its adapters.  Adapters created through
        this mechanism may safely store system-specific state.

        If you want to register an adapter that will be created through
        getComponent, but you don't require (or don't want) your adapter to be
        cached and kept alive for the lifetime of this Componentized object,
        set the attribute 'temporaryAdapter' to True on your adapter class.

        If you want to automatically register an adapter for all appropriate
        interfaces (with addComponent), set the attribute 'multiComponent' to
        True on your adapter class.
        """
        registry = getRegistry(registry)
        k = util.qual(interface)
        if self._adapterCache.has_key(k):
            return self._adapterCache[k]
        else:
            adapter = interface.__adapt__(self)
            if hasattr(adapter, "__class__"):
                fixClassImplements(adapter.__class__)
            if adapter is not None and adapter is not _Nothing and not (
                hasattr(adapter, "temporaryAdapter") and
                adapter.temporaryAdapter):
                self._adapterCache[k] = adapter
                if (hasattr(adapter, "multiComponent") and
                    adapter.multiComponent):
                    self.addComponent(adapter)
            return adapter
开发者ID:comfuture,项目名称:numbler,代码行数:32,代码来源:compyCompat.py


示例3: remember

    def remember(self, adapter, interface=None):
        """Remember an object that implements some interfaces.
        Later, calls to .locate which are passed an interface implemented
        by this object will return this object.

        If the 'interface' argument is supplied, this object will only
        be remembered for this interface, and not any of
        the other interfaces it implements.
        """
        if interface is None:
            interfaceList = megaGetInterfaces(adapter)
            if not interfaceList:
                interfaceList = [dataqual]
        else:
            interfaceList = [qual(interface)]
        if self._remembrances is None:
            self._remembrances = {}
        for interface in interfaceList:
            self._remembrances[interface] = adapter
        return self
开发者ID:comfuture,项目名称:numbler,代码行数:20,代码来源:context.py


示例4: locate

    def locate(self, interface, depth=1, _default=object()):
        """Locate an object which implements a given interface.
        Objects will be searched through the context stack top
        down.
        """
        key = qual(interface)
        currentContext = self
        while True:
            if depth < 0:
                full = []
                while True:
                    try:
                        full.append(self.locate(interface, len(full)+1))
                    except KeyError:
                        break
                #print "full", full, depth
                if full:
                    return full[depth]
                return None

            _remembrances = currentContext._remembrances
            if _remembrances is not None:
                rememberedValue = _remembrances.get(key, _default)
                if rememberedValue is not _default:
                    depth -= 1
                    if not depth:
                        return rememberedValue

            # Hook for FactoryContext and other implementations of complex locating
            locateHook = currentContext.locateHook
            if locateHook is not None:
                result = locateHook(interface)
                if result is not None:
                    currentContext.remember(result, interface)
                    return result

            contextParent = currentContext.parent
            if contextParent is None:
                raise KeyError, "Interface %s was not remembered." % key

            currentContext = contextParent
开发者ID:comfuture,项目名称:numbler,代码行数:41,代码来源:context.py


示例5: addComponent

    def addComponent(self, component, ignoreClass=0, registry=None):
        """
        Add a component to me, for all appropriate interfaces.

        In order to determine which interfaces are appropriate, the component's
        provided interfaces will be scanned.

        If the argument 'ignoreClass' is True, then all interfaces are
        considered appropriate.

        Otherwise, an 'appropriate' interface is one for which its class has
        been registered as an adapter for my class according to the rules of
        getComponent.

        @return: the list of appropriate interfaces
        """
        if hasattr(component, "__class__"):
            fixClassImplements(component.__class__)
        for iface in declarations.providedBy(component):
            if (ignoreClass or
                (self.locateAdapterClass(self.__class__, iface, None, registry)
                 == component.__class__)):
                self._adapterCache[util.qual(iface)] = component
开发者ID:comfuture,项目名称:numbler,代码行数:23,代码来源:compyCompat.py


示例6: megaGetInterfaces

def megaGetInterfaces(adapter):
    return [qual(x) for x in providedBy(adapter)]
开发者ID:comfuture,项目名称:numbler,代码行数:2,代码来源:context.py


示例7: megaGetInterfaces

def megaGetInterfaces(adapter):
    adrs = [qual(x) for x in compy.getInterfaces(adapter)]
    ## temporarily turn this off till we need it
    if False: #hasattr(adapter, '_adapterCache'):
        adrs.extend(adapter._adapterCache.keys())
    return adrs
开发者ID:Rafav,项目名称:iteexe,代码行数:6,代码来源:context.py


示例8: configure

 def configure(self, boundTo, results):
     raise NotImplementedError, "Implement in %s" % util.qual(self.__class__)
开发者ID:Rafav,项目名称:iteexe,代码行数:2,代码来源:annotate.py


示例9: __repr__

 def __repr__(self):
     if self.interface is None:
         return "Object(None)"
     return "Object(interface=%s)" % util.qual(self.interface)
开发者ID:Rafav,项目名称:iteexe,代码行数:4,代码来源:annotate.py


示例10: unsetComponent

 def unsetComponent(self, interfaceClass):
     """Remove my component specified by the given interface class."""
     del self._adapterCache[util.qual(interfaceClass)]
开发者ID:comfuture,项目名称:numbler,代码行数:3,代码来源:compyCompat.py


示例11: from_string

 def from_string(self, string):
     if not self.convert_from:
         raise NotImplementedError("Implement in %s" %
                                   util.qual(self.__class__))
     self.value = self.convert_from(string)
开发者ID:UfSoft,项目名称:ILog-Twisted,代码行数:5,代码来源:annotate.py


示例12: to_string

 def to_string(self):
     if not self.convert_to:
         raise NotImplementedError("Implement in %s" %
                                   util.qual(self.__class__))
     return self.convert_to()
开发者ID:UfSoft,项目名称:ILog-Twisted,代码行数:5,代码来源:annotate.py


示例13: coerce

 def coerce(self, val, configurable):
     raise NotImplementedError, "Implement in %s" % util.qual(self.__class__)
开发者ID:Rafav,项目名称:iteexe,代码行数:2,代码来源:annotate.py


示例14: __repr__

 def __repr__(self):
     if self.iface is not None:
         return "%s(interface=%s)" % (self.__class__.__name__, util.qual(self.iface))
     return self.__class__.__name__ + "()"
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:4,代码来源:annotate.py


示例15: setComponent

 def setComponent(self, interfaceClass, component):
     """
     """
     if hasattr(component, "__class__"):
         fixClassImplements(component.__class__)
     self._adapterCache[util.qual(interfaceClass)] = component
开发者ID:comfuture,项目名称:numbler,代码行数:6,代码来源:compyCompat.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python new.classobj函数代码示例发布时间:2022-05-27
下一篇:
Python util.maybeDeferred函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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