Michael Bayer wrote:
> works for me:

I tried adapting your example, which admittedly works :-), to a scenario 
that better resembles mine, but now the property is overriden simply, 
even when I use ``exclude_properties``.

Note that the setup is overly complex, but this should be seen in the 
light of a larger setup (as you've previously guided me towards, 
incidentally).

from sqlalchemy import *
from sqlalchemy.orm import *

e = create_engine('sqlite://')
m = MetaData(e)

t1= Table(
     't1', m,
     Column('id', Integer, primary_key=True),
     Column('col', String(50)),
     )
t1.create()

t2= Table(
     't2', m,
     Column('id', Integer, ForeignKey("t1.id"), primary_key=True),
     Column('data', String(50)),
     )
t2.create()

class T1(object):
     pass

class T2(T1):
     @property
     def col(self):
         return u"Some read-only value."

polymorphic = (
     [T2], t1.join(t2))

mapper(T1, t1)
mapper(
     T2, t2,
     exclude_properties=('col',),
     with_polymorphic=polymorphic,
     inherits=T1,
     inherit_condition=(t1.c.id==t2.c.id),
     )

sess = sessionmaker()()
x = T2()

assert type(T2.col) is property

x.data = "some data"
sess.save(x)
sess.commit()
sess.clear()

assert sess.query(T2).one().data == "some data"
assert sess.query(T2).one().col == u"Some read-only value."

x = sess.query(T2).one()
x.data = "some new data"
sess.commit()
assert sess.query(T2).one().data == "some new data"

\malthe

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to