[Zope-dev] can't register adapters for classes with metaclasses
Tres Seaver
tseaver at palladion.com
Sun Feb 27 12:22:05 EST 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 02/27/2011 06:24 AM, Chris Withers wrote:
> This is particularly problematic when using the common case of
> SQLAlchemy declaratively mapped model classes.
>
> The attached unit test when run will fail with:
>
> Error in test test_provideAdapter (test_sa.TestAdapter)
> Traceback (most recent call last):
> File "/usr/local/lib/python2.6/unittest.py", line 279, in run
> testMethod()
> File "test_sa.py", line 25, in test_provideAdapter
> provideAdapter(MyAdapter,Model)
> File
> "zope.component-3.10.0-py2.6.egg/zope/component/globalregistry.py", line
> 72, in provideAdapter
> base.registerAdapter(factory, adapts, provides, name, event=False)
> File "zope.component-3.10.0-py2.6.egg/zope/component/registry.py",
> line 182, in registerAdapter
> required = _getAdapterRequired(factory, required)
> File "zope.component-3.10.0-py2.6.egg/zope/component/registry.py",
> line 414, in _getAdapterRequired
> for r in required:
> TypeError: 'DeclarativeMeta' object is not iterable
>
> Why is that and how should I register an adapter against such a class?
UTSL: the 'required' argument passed to 'registerAdapter' is supposed
to be a sequence of interfaces or classes, not a single interface or
class. If a class, then it must be something which can be passed to
'implementedBy'.
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1qiD0ACgkQ+gerLs4ltQ57FgCgqFiGvQ9c3A8q8QYo1JmUR4UY
3PsAoLZxrDy9Q56hedSAD1v4saHtXVhf
=2veh
-----END PGP SIGNATURE-----
More information about the Zope-Dev
mailing list