Re: [SQLObject] How can return Yes/No for bool
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Scott R. <sc...@to...> - 2004-03-30 18:38:53
|
On Tue, 2004-03-30 at 13:20, Samir Patel wrote: > Is there anyway in sqlobject to return __repr__ of boolCol to Yes/No instead > of True/False? You could use a get overrider: class Food(SQLObject): madeFromPeanutButter = BoolCol() def _get_madeFromPeanutButter(self): if self._SO_get_madeFromPeanutButter(): return "Yes" else: return "No" And you'd probably want a setter, too - you can probably make a better one than this. def _set_madeFromPeanutButter(self, value): if value in ("no","No","No", False, 0, "Non"): self._SO_set_madeFromPeanutButter(False): else: self._SO_set_madeFromPeanutButter(True) |