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


Python IRequest.implementedBy方法代码示例

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


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

示例1: test_subclass_mutate_before_providedBy

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import implementedBy [as 别名]
    def test_subclass_mutate_before_providedBy(self):
        from pyramid.interfaces import IRequest
        from pyramid.request import Request
        from pyramid.util import InstancePropertyHelper

        class RequestSub(Request):
            pass

        req = RequestSub({})
        helper = InstancePropertyHelper()
        helper.apply_properties(req, {'b': 'b'})

        self.assertTrue(IRequest.providedBy(req))
        self.assertTrue(IRequest.implementedBy(RequestSub))
开发者ID:AlanMachado,项目名称:pyramid,代码行数:16,代码来源:test_request.py

示例2: test_subclass

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import implementedBy [as 别名]
    def test_subclass(self):
        from pyramid.interfaces import IRequest
        from pyramid.request import Request

        class RequestSub(Request):
            pass

        self.assertTrue(hasattr(Request, '__provides__'))
        self.assertTrue(hasattr(Request, '__implemented__'))
        self.assertTrue(hasattr(Request, '__providedBy__'))
        self.assertFalse(hasattr(RequestSub, '__provides__'))
        self.assertTrue(hasattr(RequestSub, '__providedBy__'))
        self.assertTrue(hasattr(RequestSub, '__implemented__'))

        self.assertTrue(IRequest.implementedBy(RequestSub))
        # The call to implementedBy will add __provides__ to the class
        self.assertTrue(hasattr(RequestSub, '__provides__'))
开发者ID:AlanMachado,项目名称:pyramid,代码行数:19,代码来源:test_request.py

示例3: test_subclass_with_implementer

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import implementedBy [as 别名]
    def test_subclass_with_implementer(self):
        from pyramid.interfaces import IRequest
        from pyramid.request import Request
        from pyramid.util import InstancePropertyHelper
        from zope.interface import implementer

        @implementer(IRequest)
        class RequestSub(Request):
            pass

        self.assertTrue(hasattr(Request, '__provides__'))
        self.assertTrue(hasattr(Request, '__implemented__'))
        self.assertTrue(hasattr(Request, '__providedBy__'))
        self.assertTrue(hasattr(RequestSub, '__provides__'))
        self.assertTrue(hasattr(RequestSub, '__providedBy__'))
        self.assertTrue(hasattr(RequestSub, '__implemented__'))

        req = RequestSub({})
        helper = InstancePropertyHelper()
        helper.apply_properties(req, {'b': 'b'})

        self.assertTrue(IRequest.providedBy(req))
        self.assertTrue(IRequest.implementedBy(RequestSub))
开发者ID:AlanMachado,项目名称:pyramid,代码行数:25,代码来源:test_request.py

示例4: test_class_implements

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import implementedBy [as 别名]
 def test_class_implements(self):
     from pyramid.interfaces import IRequest
     klass = self._getTargetClass()
     self.assertTrue(IRequest.implementedBy(klass))
开发者ID:deshank,项目名称:pyramid,代码行数:6,代码来源:test_request.py


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