attributes defined in mapper do not show up in python attribute dict

Issue #1223 resolved
Former user created an issue

When defining a property in the mapper using relation, this does not show up when doing

though other properties/attributes
defined in both the tables and the classes do.

Is there a reason for this inconsistency?

Eg.
'patient_cells' in mapper(Patient, patient_table,
                properties={'patient_cells':relation(Cell, backref='patient')}) should be listed.

Thanks, Faheem Mitha
        faheem@email.unc.edu

Comments (1)

  1. Mike Bayer repo owner

    dict will be empty if nothing has been placed in it.

    For a description of the technique SQLAlchemy uses to instrument attributes, see http://www.python.org/doc/2.4.2/ref/descriptors.html .

    example:

    from sqlalchemy import *
    from sqlalchemy.orm import *
    
    metadata = MetaData()
    
    foo = Table('nodes', metadata,
        Column('id', Integer, primary_key=True),
        Column('data', String)
    )
    
    class Foo(object):
        pass
    
    mapper(Foo, foo)
    
    f = Foo()
    f.data = "some data"
    assert f.__dict__['data']('data') == "some data"
    
  2. Log in to comment