nich2o, el 15 de abril a las 22:22 me escribiste:
> >You can make you own custom column. See col.py for examples. I can send
> >you a personalized column I done to check that a value stored on a
> >PickleCol is a tuple, let me know if you want it.
>
> Thank you for your anwser ! If you can copy / paste your code, that
> would be great !
Sure, I'll post it to the list so it can help other people too (I thought
I did it once but I couldn't find it on the mailing list archives):
class TupleValidator(PickleValidator):
"""
Validator for tuple types. A tuple type is simply a pickle type
that validates that the represented type is a tuple.
"""
def to_python(self, value, state):
value = super(TupleValidator, self).to_python(value, state)
if value is None:
return None
if isinstance(value, tuple):
return value
raise Invalid("expected a tuple in the TupleCol '%s', got %s %r
instead" % \
(self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
return None
if not isinstance(value, tuple):
raise Invalid("expected a tuple in the TupleCol '%s', got %s %r
instead" % \
(self.name, type(value), value), value, state)
return super(TupleValidator, self).from_python(value, state)
class SOTupleCol(SOPickleCol):
def createValidators(self):
return [TupleValidator(name=self.name)]
class TupleCol(PickleCol):
baseClass = SOTupleCol
--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
.------------------------------------------------------------------------,
\ GPG: 5F5A8D05 // F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05 /
'--------------------------------------------------------------------'
No recuerdo las flores, no conozco el viento
Aquí donde envejecen juntos presos y carceleros
Los días no pasan, el tiempo no pasa
Y vivimos contando el tiempo
Y moriremos contando el tiempo
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss