|
From: Igor M. <dow...@gm...> - 2006-01-05 06:50:33
|
Hi guys, today I have a new problem. Often times, there are forms in which
one of the fields is an id corresponding to an id in a database row
somewhere, for example:
class Person(SQLObject):
name =3D StringCol()
phones =3D MultipleJoin('Phone')
class Phone(SQLObject):
number =3D IntCol()
person =3D ForeignKey('Person')
class NewPhoneSchema(formencode.Schema):
number =3D validators.Int()
personId =3D IntCol()
in NewPersonSchema, I want personId to automatically check using the Person
model if personId points to a real existing person. It would probably be
very easy to add a custom schema whose to_python method would do it, but
there must be a better way to do it in "general" right? Because if I had to
makes schemas for say 10 forms, it would get tiring very quickly to do the
same exact thing. Plus, the author of formencode wrote sqlobject as well, s=
o
he probably had to do this at one point.
Any ideas?
Thanks,
Igor
|