I've got a one-to-one relationship something like this.

class Person(object):
    pass
class Photo(object):
    pass

persons_table = Table('persons', metadata,
    Column('id', Integer, primary_key=True),
    Column('firstname', String(255),
    Column('lastname', String(255),
    ...
    )
photos_table = Table('photos', metadata,
    Column('person_id', Integer, primary_key=True),
    Column('photo',),
    ForeignKeyConstraint(['person_id'],
        ['persons.id'],'persons_photos_fk')
    )

photomapper = mapper(Photo, photos_table)
personmapper = mapper(Person, persons_table,
    properties={'photo':relation(Photo, uselist=False)})

And now to access a person's photo I have to do "person.photo.photo". Is
there anyway I can do "person.photo" instead and still have it lazy load
the photo? I could make a getPhoto() method on the class but is a
property possible?

Aaron Spike

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to