Hi All,

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?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
           - http://www.simplistix.co.uk
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer
from unittest import TestCase
from zope.component import provideAdapter
from zope.interface import implements,Interface


class TestAdapter(TestCase):
    
    def test_provideAdapter(self):
        # setup
        Base = declarative_base()
        class Model(Base):
            __tablename__='model'
            id = Column('id', Integer, primary_key=True)

        class IMyInterface(Interface):
            pass

        class MyAdapter:
            implements(IMyInterface)

        provideAdapter(MyAdapter,Model)
_______________________________________________
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 )

Reply via email to