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

Python zapi.queryMultiAdapter函数代码示例

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

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



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

示例1: testUnnamedViewThatProvidesAnInterface

    def testUnnamedViewThatProvidesAnInterface(self):
        ob = Ob()
        self.assertEqual(
            zapi.queryMultiAdapter((ob, Request(IR)), IV), None)

        xmlconfig(StringIO(template %
            '''
            <view factory="zope.app.component.tests.views.V1"
                  for="zope.app.component.tests.views.IC"
                  type="zope.app.component.tests.views.IR"
                  />
            '''
            ))

        v = zapi.queryMultiAdapter((ob, Request(IR)), IV)
        self.assertEqual(v, None)

        xmlconfig(StringIO(template %
            '''
            <view factory="zope.app.component.tests.views.V1"
                  for="zope.app.component.tests.views.IC"
                  type="zope.app.component.tests.views.IR"
                  provides="zope.app.component.tests.views.IV"
                  />
            '''
            ))

        v = zapi.queryMultiAdapter((ob, Request(IR)), IV)
        self.assertEqual(v.__class__, V1)
开发者ID:BackupTheBerlios,项目名称:cctools-svn,代码行数:29,代码来源:test_directives.py


示例2: testView_w_multiple_factories

    def testView_w_multiple_factories(self):
        xmlconfig(StringIO(template %
            '''
            <view name="test"
                  factory="zope.app.component.tests.adapter.A1
                           zope.app.component.tests.adapter.A2
                           zope.app.component.tests.adapter.A3
                           zope.app.component.tests.views.V1"
                  for="zope.app.component.tests.views.IC"
                  type="zope.app.component.tests.views.IV"/>
            '''
            ))

        ob = Ob()

        # The view should be a V1 around an A3, around an A2, around
        # an A1, anround ob:
        view = zapi.queryMultiAdapter((ob, Request(IV)), name=u'test')
        self.assertEqual(view.__class__, V1)
        a3 = view.context
        self.assertEqual(a3.__class__, A3)
        a2 = a3.context[0]
        self.assertEqual(a2.__class__, A2)
        a1 = a2.context[0]
        self.assertEqual(a1.__class__, A1)
        self.assertEqual(a1.context[0], ob)
开发者ID:BackupTheBerlios,项目名称:cctools-svn,代码行数:26,代码来源:test_directives.py


示例3: _initSettings

    def _initSettings(self, obj, profile_id, obj_path):
        stool = getToolByName(self, 'portal_setup', None)
        if stool is None:
            return

        context = stool._getImportContext(profile_id)
        file_ids = context.listDirectory('types')
        for file_id in file_ids or ():
            filename = 'types/%s' % file_id
            body = context.readDataFile(filename)
            if body is None:
                continue

            root = parseString(body).documentElement
            new_id = str(root.getAttribute('name'))
            if not new_id:
                # BBB: for CMF 1.5 profiles
                new_id = str(root.getAttribute('id'))
            if new_id != obj_path[0]:
                continue

            # BBB: for CMF 1.5 profiles
            meta_type = str(root.getAttribute('kind'))
            if not meta_type:
                meta_type = str(root.getAttribute('meta_type'))
            if meta_type != self.klass.meta_type:
                continue

            importer = zapi.queryMultiAdapter((obj, context), IBody)
            if importer is None:
                continue

            importer.body = body
            return
开发者ID:goschtl,项目名称:zope,代码行数:34,代码来源:typeinfo.py


示例4: _extractCachingPolicies

 def _extractCachingPolicies(self):
     fragment = self._doc.createDocumentFragment()
     for policy_id, policy in self.context.listPolicies():
         exporter = zapi.queryMultiAdapter((policy, self.environ), INode)
         if exporter:
             fragment.appendChild(exporter.node)
     return fragment
开发者ID:goschtl,项目名称:zope,代码行数:7,代码来源:cachingpolicymgr.py


示例5: _initIndexes

    def _initIndexes(self, node):
        for child in node.childNodes:
            if child.nodeName != 'index':
                continue
            if child.hasAttribute('deprecated'):
                continue
            zcatalog = self.context

            idx_id = str(child.getAttribute('name'))
            if idx_id not in zcatalog.indexes():
                extra = _extra()
                for sub in child.childNodes:
                    if sub.nodeName == 'extra':
                        name = str(sub.getAttribute('name'))
                        value = str(sub.getAttribute('value'))
                        setattr(extra, name, value)
                extra = extra.__dict__ and extra or None

                meta_type = str(child.getAttribute('meta_type'))
                zcatalog.addIndex(idx_id, meta_type, extra)

            idx = zcatalog._catalog.getIndex(idx_id)
            importer = zapi.queryMultiAdapter((idx, self.environ), INode)
            if importer:
                importer.node = child
开发者ID:goschtl,项目名称:zope,代码行数:25,代码来源:exportimport.py


示例6: _initSettings

    def _initSettings(self, obj, profile_id, obj_path):
        stool = getToolByName(self, 'portal_setup', None)
        if stool is None:
            return

        context = stool._getImportContext(profile_id)
        body = context.readDataFile('actions.xml')
        if body is None:
            return

        settings_node = None
        root = parseString(body).documentElement
        for node in root.childNodes:
            if node.nodeName != 'object':
                continue
            for obj_id in obj_path:
                for child in node.childNodes:
                    if child.nodeName != 'object':
                        continue
                    if child.getAttribute('name') != obj_id:
                        continue
                    if child.getAttribute('meta_type') == self.klass.meta_type:
                        settings_node = child
                    else:
                        node = child
                    break

        importer = zapi.queryMultiAdapter((obj, context), INode)
        if importer is None:
            return

        importer.node = settings_node
        return
开发者ID:goschtl,项目名称:zope,代码行数:33,代码来源:actions.py


示例7: _exportNode

 def _exportNode(self):
     """Export the object as a DOM node.
     """
     node = self._getObjectNode('index')
     for set in self.context.filteredSets.values():
         exporter = zapi.queryMultiAdapter((set, self.environ), INode)
         node.appendChild(exporter.node)
     return node
开发者ID:goschtl,项目名称:zope,代码行数:8,代码来源:exportimport.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python interfaces.IUnauthenticatedPrincipal类代码示例发布时间:2022-05-26
下一篇:
Python zapi.getUtility函数代码示例发布时间: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