Re: [Zope-dev] can't register adapters for classes with metaclasses

2011-02-27 Thread Chris Withers
On 27/02/2011 17:22, Tres Seaver wrote:
>> 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'.

Thanks. I blame mcdonc, got used to having actual docs for everything ;-)

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
___
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )


Re: [Zope-dev] can't register adapters for classes with metaclasses

2011-02-27 Thread Tres Seaver
-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  tsea...@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-

___
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )