Re: can't register adapters for classes with metaclasses

Tres Seaver <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
-----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          [email protected]
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-----

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.