commit | author | age
|
5bf23f
|
1 |
from pyramid.threadlocal import get_current_registry |
CM |
2 |
|
0c29cf
|
3 |
|
5bf23f
|
4 |
class ZCAConfiguratorMixin(object): |
CM |
5 |
def hook_zca(self): |
d295cd
|
6 |
""" Call :func:`zope.component.getSiteManager.sethook` with the |
CM |
7 |
argument :data:`pyramid.threadlocal.get_current_registry`, causing |
5bf23f
|
8 |
the :term:`Zope Component Architecture` 'global' APIs such as |
CM |
9 |
:func:`zope.component.getSiteManager`, |
|
10 |
:func:`zope.component.getAdapter` and others to use the |
d295cd
|
11 |
:app:`Pyramid` :term:`application registry` rather than the Zope |
CM |
12 |
'global' registry.""" |
58bd32
|
13 |
from zope.component import getSiteManager |
0c29cf
|
14 |
|
5bf23f
|
15 |
getSiteManager.sethook(get_current_registry) |
CM |
16 |
|
|
17 |
def unhook_zca(self): |
d295cd
|
18 |
""" Call :func:`zope.component.getSiteManager.reset` to undo the |
CM |
19 |
action of :meth:`pyramid.config.Configurator.hook_zca`.""" |
58bd32
|
20 |
from zope.component import getSiteManager |
5bf23f
|
21 |
|
0c29cf
|
22 |
getSiteManager.reset() |