Author: phd
Date: 2005-01-07 11:20:49 +0000 (Fri, 07 Jan 2005)
New Revision: 520
Modified:
home/phd/SQLObject/inheritance/sqlobject/col.py
Log:
Merged patch from rev 519: changed IntValidator.toPython - it now calls int() to convert non-integer value.
Modified: home/phd/SQLObject/inheritance/sqlobject/col.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/col.py 2005-01-07 11:16:34 UTC (rev 519)
+++ home/phd/SQLObject/inheritance/sqlobject/col.py 2005-01-07 11:20:49 UTC (rev 520)
@@ -386,10 +386,16 @@
def toPython(self, value, state):
if value is None:
return None
- if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
+ if isinstance(value, (int, long, sqlbuilder.SQLExpression)):
+ return value
+ try:
+ try:
+ return int(value)
+ except OverflowError: # for Python 2.2
+ return long(value)
+ except:
raise validators.InvalidField("expected an int in the IntCol '%s', got %s instead" % \
(self.name, type(value)), value, state)
- return value
class SOIntCol(SOCol):
validatorClass = IntValidator # can be overriden in descendants
|