works for me:
from sqlalchemy import *
from sqlalchemy.orm import *
e = create_engine('sqlite://')
m = MetaData(e)
t= Table('t1', m,
Column('id', Integer, primary_key=True),
Column('col', String(50)),
Column('data', String(50)),
)
t.create()
class Mapper(object):
@property
def col(self):
return u"Some read-only value."
mapper(Mapper, t, exclude_properties=('col',))
sess = sessionmaker()()
x = Mapper()
x.data = "some data"
sess.save(x)
sess.commit()
sess.clear()
assert sess.query(Mapper).one().data == "some data"
assert sess.query(Mapper).one().col == u"Some read-only value."
x = sess.query(Mapper).one()
x.data = "some new data"
sess.commit()
assert sess.query(Mapper).one().data == "some new data"
On Jul 18, 2008, at 2:24 PM, Malthe Borch wrote:
>
> I have a table 'test' that defines a column 'col'. I map this table
> on:
>
> class Mapper(object):
> @property
> def col(self):
> return u"Some read-only value."
>
> passing exclude_properties=('col',).
>
> However, when I save and commit an instance of Mapper, I get:
>
> [snip]
>
> UnmappedColumnError: No column test.col is configured on mapper
> Mapper...
>
> This is on SQLAlchemy 0.4.6.
>
> \malthe
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---