[SQL-CVS] r1117 - SQLObject/branches/0.7-bugfix/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-10-18 13:28:15
|
Author: phd
Date: 2005-10-18 13:28:02 +0000 (Tue, 18 Oct 2005)
New Revision: 1117
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/col.py
Log:
Merged patch from revision 1116 from the trunk - report the repr(value) along with its type.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/col.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/col.py 2005-10-18 13:26:55 UTC (rev 1116)
+++ SQLObject/branches/0.7-bugfix/sqlobject/col.py 2005-10-18 13:28:02 UTC (rev 1117)
@@ -549,15 +549,15 @@
except OverflowError: # for Python 2.2
return long(value)
except:
- raise validators.Invalid("expected an int in the IntCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected an int in the IntCol '%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, (int, long, sqlbuilder.SQLExpression)):
- raise validators.Invalid("expected an int in the IntCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected an int in the IntCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
return value
class SOIntCol(SOCol):
@@ -634,15 +634,15 @@
try:
return float(value)
except:
- raise validators.Invalid("expected a float in the FloatCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a float in the FloatCol '%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, (int, long, float, sqlbuilder.SQLExpression)):
- raise validators.Invalid("expected a float in the FloatCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a float in the FloatCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
return value
class SOFloatCol(SOCol):
@@ -841,8 +841,8 @@
try:
stime = time.strptime(value, self.format)
except:
- raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \
- (self.format, self.name, type(value)), value, state)
+ raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
+ (self.format, self.name, type(value), value), value, state)
secs = time.mktime(stime)
return datetime.datetime.fromtimestamp(secs)
@@ -853,8 +853,8 @@
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
- raise validators.Invalid("expected a datetime in the DateTimeCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a datetime in the DateTimeCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
if mxdatetime_available:
class MXDateTimeValidator(validators.DateValidator):
@@ -872,8 +872,8 @@
try:
stime = time.strptime(value, self.format)
except:
- raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \
- (self.format, self.name, type(value)), value, state)
+ raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
+ (self.format, self.name, type(value), value), value, state)
return DateTime.mktime(stime)
def from_python(self, value, state):
@@ -883,8 +883,8 @@
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
- raise validators.Invalid("expected a mxDateTime in the DateTimeCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a mxDateTime in the DateTimeCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
class SODateTimeCol(SOCol):
datetimeFormat = '%Y-%m-%d %H:%M:%S'
@@ -1041,8 +1041,8 @@
if isinstance(value, array_type): # MySQL
return value.tostring()
return str(value) # buffer => string
- raise validators.Invalid("expected a string in the BLOBCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a string in the BLOBCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
@@ -1091,8 +1091,8 @@
value = value.encode("ascii")
if isinstance(value, str):
return pickle.loads(value)
- raise validators.Invalid("expected a pickle string in the PickleCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a pickle string in the PickleCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
|