On Tue, 2003-07-29 at 01:21, Javier Ruere wrote:
> I was trying to make a BoolCol class just to learn how things work.
> I grabed the StringCol and SOStringCol classes, changed things and the
> generated SQL was right. This was very easy to make!!
> Now I was wondering if there is a way I can define filters for the
> data, both in it's way in and out of the DB, so that I can take whatever
> the Python type is and change it to what the DB wants. In this case
> change the int to a '1' or the like for SQLite and 'TRUE' for PostgreSQL
> (don't know MySQL) and the inverse operation when read from the DB. Is
> there a way to do this?
No, there isn't a way to do this generally. It's on the top of my
hard-things-to-do list for SQLObject (it's not terribly hard, but it's
not trivial).
Until then you have to do things like:
def _set_someBool(self, value):
if value:
value = 't'
else:
value = 'f'
self._SO_set_someBool(self, value)
> PS: I'm developing an app from scratch, should I be using the SQLObject
> from CVS? Has it's structure changed much from v0.4?
Structure hasn't changed, just some bug fixes. Structure probably will
change, though, when I have a chance to commit some more time to
SQLObject (but that's at least three weeks away) -- I am planning some
significant renaming. But handling that change should be a simple
search-and-replace, and I'll document the replacements. I'm going to
avoid requiring any non-trivial changes to people's code that uses
SQLObject (renaming is trivial, restructuring isn't).
Ian
|