There's a subtle difference between the standard AdapterRegistry
(from zope.interface.adapter) used for the global component registry
and PersistentAdapterRegistry (from
zope.component.persistentregistry) -- apart from the fact that the
latter is persistent:
When you set the __bases__ property on AdapterRegistry, it tells the
adapter registries higher up in the hierarchy that it's there by
calling an _addSubregistry() method on them,
PersistentAdapterRegistry doesn't do this and doesn't have an
_addSubregistry() method.
Usually this doesn't come into effect because the global component
registry with a regular AdapterRegistry is typically highest in the
hierarchy:
global component registry
w/ AdapterRegistry
^
|
|
persistent component registry (e.g. ++etc++site)
w/ PersistentAdapterRegistry
^
|
|
persistent component registry (e.g. ++etc++site)
w/ PersistentAdapterRegistry
|
...
Now, let's imagine you actually put a "global" (that means non-
persistent) component registry *after* a persistent component
registry, e.g. you have
global component registry
w/ AdapterRegistry
^
|
|
persistent component registry (e.g. ++etc++site)
w/ PersistentAdapterRegistry
^
|
|
non-persistent component registry (created during traversal)
w/ AdapterRegistry
Creating that non-persistent component registry works fine, you can
simply use BaseGlobalComponents(). However, when you set the
__bases__, AdapterRegistry will try to call _addSubregistry() on the
PersistentAdapterRegistry that's higher up in the hierarchy and the
whole thing goes ka-boom:
Traceback (most recent call last):
...
File "/Users/philipp/dev/ploneout/src/kss.core/kss/core/
azaxview.py", line 60, in __init__
self._sitemanager.__bases__ = (next, )
...
AttributeError: 'PersistentAdapterRegistry' object has no attribute
'_addSubregistry'
This is quite annoying. Do I have to write my own component registry,
subclassign from BaseGlobalComponents so that I won't use
AdapterRegistry but a variant that doesn't end up assuming
_addSubregistry on the other registries? Or is the _addSubregistry
thign some legacy that can be removed (it doesn't seem to be used at
all in Zope 3 currently)?
Philipp
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com