Hi all, sorry for the inane question, but I think I must have lost sight of the woods with all these trees all over the place. I am new to TG, very puzzled, and I think I'm missing something simple.
I've been trying to use the CalendarDateTimePicker to store an value in
a DateTime column (just as in CatWalk). I get a 500 error when trying to
add a new row using my code. Test data renders OK, and I've checked that
the default format for validator.DateTimeConverter matches up. I think
'Name' (see below) is a red herring...
If anyone could point me at any docs or earlier posts that might shed a
light (SQLObject? FormEncode?) I'd be very grateful. Currently reading
the source for CatWalk to see the Right Way to do it, but i'm relatively
unfamiliar with javascript and a 1000+ line module may take me a while
to fully grasp :-/.
Here's what I'm doing, (using 1.01, BTW)
---> in model.py
class Thing(SLObject):
Ends = DateTimeCol(title="Ends at")
Name = StringCol(title="Name",notNone=True)
---> in controllers.py:
class AddItemFormSchema(validators.Schema):
# ...
finish = validators.DateTimeConverter()
what = validators.NotEmpty()
# ...
class AddItemFormFields(widgets.WidgetsList):
# ...
finish = widgets.CalendarDateTimePicker()
what = widgets.TextField()
# ...
class Root:
# template1 contains "${sa(action="new_thing")}"
@expose(.templates.template1)
def function(self):
# ...
myForm = widgets.TableForm(fields=AddItemFormFields(),
validator=AddItemFormSchema())
# ...
return dict(theForm=myForm)
@expose(.templates.template2)
def new_thing():
# ...
item = Thing(Name=['what'], Ends=kw['finish'])
# ...
---> The 500 error:
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.3-py2.4.egg/sqlobject/declarative.py",
line 93, in _wrapper
return fn(self, *args, **kwargs)
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.3-py2.4.egg/sqlobject/main.py",
line 1205, in __init__
self._create(id, **kw)
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.3-py2.4.egg/sqlobject/main.py",
line 1229, in _create
self.set(**kw)
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.3-py2.4.egg/sqlobject/main.py",
line 1088, in set
kw[name] = dbValue = from_python(value, self._SO_validatorState)
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.3-py2.4.egg/sqlobject/col.py",
line 966, in from_python
(self.name, type(value), value), value, state)
Invalid: expected a datetime in the DateTimeCol 'Ends', got <type
'unicode'> u'2007/03/23 22:30' instead
signature.asc
Description: OpenPGP digital signature

