My application has broken moving from 1.99.4 to 1.99.7.
I have a field of type list:string (using Sqlite). In 1.99.7, dal.py
breaks at line 1405 (marked with >>>):
return str(obj)
if fieldtype.startswith('list:'):
if not obj:
obj = []
elif not isinstance(obj, (list, tuple)):
>>> obj = [int(obj)]
elif fieldtype.startswith('list:string'):
obj = [str(item) for item in obj]
else:
obj = [int(item) for item in obj]
Because my field is type list:string, startswith('list:') is True and thus
the startswith('list:string') line is never reached.
This patch appears to fix the problem, although I've not tested it
thoroughly:
--- dal.py.old 2012-03-21 07:19:12.000000000 +0000
+++ dal.py 2012-03-21 07:20:38.000000000 +0000
@@ -1398,13 +1398,13 @@
return fieldtype.encoder(obj)
if isinstance(obj, (Expression, Field)):
return str(obj)
- if fieldtype.startswith('list:'):
+ if fieldtype.startswith('list:string'):
+ obj = [str(item) for item in obj]
+ elif fieldtype.startswith('list:'):
if not obj:
obj = []
elif not isinstance(obj, (list, tuple)):
obj = [int(obj)]
- elif fieldtype.startswith('list:string'):
- obj = [str(item) for item in obj]
else:
obj = [int(item) for item in obj]
if isinstance(obj, (list, tuple)):
--
"You can have everything in life you want if you help enough other people
get what they want" - Zig Ziglar.
Who did you help today?