[Zope3-Users] sqlalchemy and FieldProperty
Darryl Cousins
darryl at darrylcousins.net.nz
Fri Dec 21 00:19:42 EST 2007
Hi,
I find that when I map a class to a table I lose the auto-magic
vaidation provided by FieldProperty when setting attributes.
class IMyObject(zope.interface.Interface):
now = zope.schema.Datatime()
class MyObject(object):
zope.interface.implements(IMyOBject)
now = zope.schema.fieldproperty(IMyObject['now'])
object_table = sqlalchemy.Table(
'object_table', z3c.zalchemy.metadata(),
sqlalchemy.Column('now', sqlalchemy.DateTime))
sqlalchemy.orm.mapper(MyObject, object_table)
obj = MyObject()
obj.now = u'Not a date time object'
If I simply remove the mapper defintion
obj = MyObject()
obj.now = u'Not a date time object'
WrongType: (u'Not a date time object', <type 'datetime.datetime'>)
Has anyone found a work around? Because I would like to have data
validated without having to write code to do so.
Regards,
Darryl
More information about the Zope3-users
mailing list