本文整理汇总了Python中twisted.python.components.proxyForInterface函数的典型用法代码示例。如果您正苦于以下问题:Python proxyForInterface函数的具体用法?Python proxyForInterface怎么用?Python proxyForInterface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了proxyForInterface函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_proxyName
def test_proxyName(self):
"""
The name of a proxy class indicates which interface it proxies.
"""
proxy = proxyForInterface(IProxiedInterface)
self.assertEqual(proxy.__name__,
"(Proxy for seishub.core.tests." + \
"test_core_twisted_compatibility.IProxiedInterface)")
开发者ID:barsch,项目名称:seishub.core,代码行数:8,代码来源:test_core_twisted_compatibility.py
示例2: test_original
def test_original(self):
"""
Proxy objects should have an C{original} attribute which refers to the
original object passed to the constructor.
"""
original = object()
proxy = proxyForInterface(IProxiedInterface)(original)
self.assertIdentical(proxy.original, original)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:8,代码来源:test_components.py
示例3: test_proxyName
def test_proxyName(self):
"""
The name of a proxy class indicates which interface it proxies.
"""
proxy = proxyForInterface(IProxiedInterface)
self.assertEquals(
proxy.__name__,
"(Proxy for "
"twisted.python.test.test_components.IProxiedInterface)")
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:test_components.py
示例4: test_multipleMethods
def test_multipleMethods(self):
"""
[Regression test] The proxy should send its method calls to the correct
method, not the incorrect one.
"""
multi = MultipleMethodImplementor()
proxy = proxyForInterface(IMultipleMethods)(multi)
self.assertEquals(proxy.methodOne(), 1)
self.assertEquals(proxy.methodTwo(), 2)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:test_components.py
示例5: test_proxyDeleteAttribute
def test_proxyDeleteAttribute(self):
"""
The attributes that proxy objects proxy should be deletable and affect
the original object.
"""
yayable = Yayable()
yayable.ifaceAttribute = None
proxy = proxyForInterface(IProxiedInterface)(yayable)
del proxy.ifaceAttribute
self.assertFalse(hasattr(yayable, 'ifaceAttribute'))
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:10,代码来源:test_components.py
示例6: test_proxySetAttribute
def test_proxySetAttribute(self):
"""
The attributes that proxy objects proxy should be assignable and affect
the original object.
"""
yayable = Yayable()
proxy = proxyForInterface(IProxiedInterface)(yayable)
thingy = object()
proxy.ifaceAttribute = thingy
self.assertIdentical(yayable.ifaceAttribute, thingy)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:10,代码来源:test_components.py
示例7: test_proxyAttribute
def test_proxyAttribute(self):
"""
Proxy objects should proxy declared attributes, but not other
attributes.
"""
yayable = Yayable()
yayable.ifaceAttribute = object()
proxy = proxyForInterface(IProxiedInterface)(yayable)
self.assertIdentical(proxy.ifaceAttribute, yayable.ifaceAttribute)
self.assertRaises(AttributeError, lambda: proxy.yays)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:10,代码来源:test_components.py
示例8: test_proxyMethod
def test_proxyMethod(self):
"""
The class created from L{proxyForInterface} passes methods on an
interface to the object which is passed to its constructor.
"""
klass = proxyForInterface(IProxiedInterface)
yayable = Yayable()
proxy = klass(yayable)
proxy.yay()
self.assertEquals(proxy.yay(), 2)
self.assertEquals(yayable.yays, 2)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:11,代码来源:test_components.py
示例9: test_interfaceInheritance
def test_interfaceInheritance(self):
"""
Proxies of subinterfaces generated with proxyForInterface should allow
access to attributes of both the child and the base interfaces.
"""
proxyClass = proxyForInterface(IProxiedSubInterface)
booable = Booable()
proxy = proxyClass(booable)
proxy.yay()
proxy.boo()
self.failUnless(booable.yayed)
self.failUnless(booable.booed)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:12,代码来源:test_components.py
示例10: repeat_call_proxy_for
def repeat_call_proxy_for(interface, provider):
"""
Constructs an implementation of interface that calls the corresponding
method on implementation twice for every call to a method.
:interface param: The zope interface that the proxy should implement.
:provider param: The underlying provider to proxy all method calls to.
"""
# proxyForInterface used so that only the methods of the interface are
# exposed. The naive implementation of _RepeatProxy forwards all methods
# rather than just the methods that are part of the interface.
return proxyForInterface(interface, originalAttribute="_original")(_RepeatProxy(_provider=provider))
开发者ID:ClusterHQ,项目名称:flocker,代码行数:12,代码来源:test_gce.py
示例11: loggedReactor
def loggedReactor(reactor):
"""
Construct and return a wrapper around the given C{reactor} which provides
all of the same interfaces, but which will log all traffic over outgoing
TCP connections it establishes.
"""
bases = []
for iface in providedBy(reactor):
if iface is IReactorTCP:
bases.append(_TCPTrafficLoggingReactor)
else:
bases.append(proxyForInterface(iface, '_reactor'))
if bases:
return type('(Logged Reactor)', tuple(bases), {})(reactor)
return reactor
开发者ID:eventable,项目名称:CalendarServer,代码行数:15,代码来源:trafficlogger.py
示例12: test_decoratedProxyMethod
def test_decoratedProxyMethod(self):
"""
Methods of the class created from L{proxyForInterface} can be used with
the decorator-helper L{functools.wraps}.
"""
base = proxyForInterface(IProxiedInterface)
class klass(base):
@wraps(base.yay)
def yay(self):
self.original.yays += 1
return base.yay(self)
original = Yayable()
yayable = klass(original)
yayable.yay()
self.assertEqual(2, original.yays)
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:16,代码来源:test_components.py
示例13: service
def service(self, services=None):
if services is None:
services = (self.xmlService(),)
#
# Make sure aggregate DirectoryService isn't making
# implementation assumptions about the IDirectoryService
# objects it gets.
#
services = tuple((
proxyForInterface(IDirectoryService)(s)
for s in services
))
class TestService(DirectoryService, QueryMixIn):
pass
return TestService("xyzzy", services)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:18,代码来源:test_aggregate.py
示例14: test_attributeCustomization
def test_attributeCustomization(self):
"""
The original attribute name can be customized via the
C{originalAttribute} argument of L{proxyForInterface}: the attribute
should change, but the methods of the original object should still be
callable, and the attributes still accessible.
"""
yayable = Yayable()
yayable.ifaceAttribute = object()
proxy = proxyForInterface(
IProxiedInterface, originalAttribute='foo')(yayable)
self.assertIdentical(proxy.foo, yayable)
# Check the behavior
self.assertEquals(proxy.yay(), 1)
self.assertIdentical(proxy.ifaceAttribute, yayable.ifaceAttribute)
thingy = object()
proxy.ifaceAttribute = thingy
self.assertIdentical(yayable.ifaceAttribute, thingy)
del proxy.ifaceAttribute
self.assertFalse(hasattr(yayable, 'ifaceAttribute'))
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:21,代码来源:test_components.py
示例15: test_implements
def test_implements(self):
"""
The resulting proxy implements the interface that it proxies.
"""
proxy = proxyForInterface(IProxiedInterface)
self.assertTrue(IProxiedInterface.implementedBy(proxy))
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:6,代码来源:test_components.py
示例16: test_provides
def test_provides(self):
"""
The resulting proxy provides the Interface that it proxies.
"""
proxy = proxyForInterface(IProxiedInterface)
self.assertTrue(IProxiedInterface.providedBy(proxy))
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:6,代码来源:test_components.py
注:本文中的twisted.python.components.proxyForInterface函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论