SqlAlchemy 5.2 listen_for_events.py

Issue #1314 resolved
Former user created an issue

The example in SQLAlchemy-0.5.2/examples/custom_attributes does not work.

mike@mike:~/src/sqlalchemy-eggs/SQLAlchemy-0.5.2/examples/custom_attributes 278> python listen_for_events.py 
Traceback (most recent call last):
  File "listen_for_events.py", line 59, in <module>
    class MyMappedClass(Base):
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/ext/declarative.py", line 543, in __init__
    _as_declarative(cls, classname, dict_)
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/ext/declarative.py", line 536, in _as_declarative
    cls.__mapper__ = mapper_cls(cls, table, properties=our_stuff, **mapper_args)
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/__init__.py", line 752, in mapper
    return Mapper(class_, local_table, *args, **params)
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/mapper.py", line 198, in __init__
    self._configure_properties()
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/mapper.py", line 481, in _configure_properties
    self._configure_property(key, prop, False)
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/mapper.py", line 616, in _configure_property
    prop.instrument_class(self)
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/properties.py", line 439, in instrument_class
    property_=self
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/attributes.py", line 1594, in register_descriptor
    manager.instrument_attribute(key, descriptor)
  File "/usr/local/ltcd/lib/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/attributes.py", line 1355, in instrument_attribute
    self._adapted.instrument_attribute(self.class_, key, inst)
  File "listen_for_events.py", line 13, in instrument_attribute
    inst.impl.extensions.insert(0, AttributeListener(key))
AttributeError: 'NoneType' object has no attribute 'extensions'

Comments (2)

  1. Log in to comment