golden hour
/usr/lib/python2.7/site-packages/zope/component/tests
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.py
16 B
Del
OK
__init__.pyc
152 B
Del
OK
__init__.pyo
152 B
Del
OK
examples.py
3.16 KB
Del
OK
examples.pyc
7.99 KB
Del
OK
examples.pyo
7.99 KB
Del
OK
test___init__.py
3.12 KB
Del
OK
test___init__.pyc
5.24 KB
Del
OK
test___init__.pyo
5.24 KB
Del
OK
test__api.py
41.84 KB
Del
OK
test__api.pyc
74.24 KB
Del
OK
test__api.pyo
74.24 KB
Del
OK
test__declaration.py
7.01 KB
Del
OK
test__declaration.pyc
12.41 KB
Del
OK
test__declaration.pyo
12.41 KB
Del
OK
test_event.py
2.3 KB
Del
OK
test_event.pyc
2.85 KB
Del
OK
test_event.pyo
2.85 KB
Del
OK
test_factory.py
3.7 KB
Del
OK
test_factory.pyc
6.09 KB
Del
OK
test_factory.pyo
6.09 KB
Del
OK
test_globalregistry.py
8.47 KB
Del
OK
test_globalregistry.pyc
14.39 KB
Del
OK
test_globalregistry.pyo
14.29 KB
Del
OK
test_hookable.py
4 KB
Del
OK
test_hookable.pyc
6.62 KB
Del
OK
test_hookable.pyo
6.62 KB
Del
OK
test_hooks.py
11.42 KB
Del
OK
test_hooks.pyc
17.43 KB
Del
OK
test_hooks.pyo
17.43 KB
Del
OK
test_interface.py
14.15 KB
Del
OK
test_interface.pyc
23.29 KB
Del
OK
test_interface.pyo
23.29 KB
Del
OK
test_persistentregistry.py
6.27 KB
Del
OK
test_persistentregistry.pyc
8.41 KB
Del
OK
test_persistentregistry.pyo
8.41 KB
Del
OK
test_registry.py
4.55 KB
Del
OK
test_registry.pyc
7.34 KB
Del
OK
test_registry.pyo
7.34 KB
Del
OK
test_security.py
9.15 KB
Del
OK
test_security.pyc
16.49 KB
Del
OK
test_security.pyo
16.49 KB
Del
OK
test_standalone.py
1.99 KB
Del
OK
test_standalone.pyc
1.77 KB
Del
OK
test_standalone.pyo
1.77 KB
Del
OK
test_zcml.py
47.22 KB
Del
OK
test_zcml.pyc
56.41 KB
Del
OK
test_zcml.pyo
56.41 KB
Del
OK
Edit: examples.py
############################################################################## # # Copyright (c) 2001, 2002, 2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Examples supporting Sphinx doctest snippets. """ import sys from zope.interface import Interface from zope.interface import implementer from zope.interface.interfaces import IInterface from zope.component._declaration import adapter from zope.component.testfiles.views import IC def write(x): sys.stdout.write('%s\n' % x) class ITestType(IInterface): pass class I1(Interface): pass class I2(Interface): pass class I3(Interface): pass class I4(Interface): pass class IGI(Interface): pass class IQI(Interface): pass class ISI(Interface): pass class ISII(Interface): pass def noop(*args): pass class U(object): def __init__(self, name): self.__name__ = name def __repr__(self): return "%s(%s)" % (self.__class__.__name__, self.__name__) @implementer(I1) class U1(U): pass @implementer(I1, I2) class U12(U): pass @adapter(I1) def handle1(x): write('handle1 %s' % x) def handle2(*objects): write( 'handle2 ' + repr(objects)) @adapter(I1) def handle3(x): write( 'handle3 %s' % x) @adapter(I1) def handle4(x): write( 'handle4 %s' % x) class GlobalRegistry: pass from zope.component.globalregistry import GlobalAdapterRegistry base = GlobalAdapterRegistry(GlobalRegistry, 'adapters') GlobalRegistry.adapters = base def clear_base(): base.__init__(GlobalRegistry, 'adapters') @implementer(I1) class Ob(object): def __repr__(self): return '<instance Ob>' ob = Ob() @implementer(I2) class Ob2(object): def __repr__(self): return '<instance Ob2>' @implementer(IC) class Ob3(object): pass @implementer(I2) class Comp(object): def __init__(self, context): self.context = context comp = Comp(1) @implementer(I3) class Comp2(object): def __init__(self, context): self.context = context class ConformsToIComponentLookup(object): """Allow a dummy sitemanager to conform/adapt to `IComponentLookup`.""" def __init__(self, sitemanager): self.sitemanager = sitemanager def __conform__(self, interface): """This method is specified by the adapter PEP to do the adaptation.""" from zope.component.interfaces import IComponentLookup if interface is IComponentLookup: return self.sitemanager def clearZCML(test=None): from zope.configuration.xmlconfig import XMLConfig import zope.component from zope.component.testing import setUp from zope.component.testing import tearDown tearDown() setUp() XMLConfig('meta.zcml', zope.component)()
Save