Re: [SQLObject] Custom Validator (unique-ness)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-09-09 01:27:05
|
On Monday, September 8, 2003, at 12:43 PM, Sidnei da Silva wrote: > Howdy, > > I was just looking at the new validator stuff, and trying to figure > out how to do something: > > I need to have a constraint on one field that the field value is > unique, but this field cannot be a primary key. So, I was thinking > about giving it a Unique validator. > > Questions: > > - It seems like the easier way to do this would be to use the > Wrapper validator, passing a callable that tests for uniqueness of a > column. Sounds right? > > - Can I put the Unique class (that tests for uniqueness given a > column name) on the include/Validators.py module? Unique is hard, because you can't test it in isolation. You'd have to look at all the other rows, whether they are in memory or not. It seems like the database would do this best. Anyway, I don't think this is the best place for a validator, it's really best done in the database. Is there a problem there? Also, Validators.py is really part of another piece of (as-yet unreleased) software I'm writing, and include/Validators.py is (and will continue to be) a direct copy of that. I'm not sure where the best place for a SQLObject-specific validator is. Ian |