本文整理汇总了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))
示例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__'))
示例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))
示例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))