ValueError in sprox.sa.provider._modify_params_for_dates

10 views
Skip to first unread message

zov...@gmail.com

unread,
Mar 2, 2016, 9:58:40 AM3/2/16
to sprox
Hi everyone,

I created a Turbogears form which had three DateTime fields. If any of widgets for those fields were TextField and would have nothing entered I would get following message trying to create new record:

ValueError: time data '' does not match format '%Y-%m-%d %H:%M:%S'

in: sprox-0.10.2-py2.7.egg/sprox/sa/provider.py,
line:
dt = datetime.strptime(value[:19], '%Y-%m-%d %H:%M:%S')

I checked sprox/sa/provider.py and found in

def _modify_params_for_dates(self, entity, params):
...


        if key in mapper.c and value is not None:

...


It looks like empty string values do not get discarded and when converted into datetime object  ValueError gets raised.


I changed the line to:


        if key in mapper.c and value is not None and value != u'':


and it looks like to work OK now, but I don't know if it breaks anything else.


With Best Regards


Ernest

Reply all
Reply to author
Forward
0 new messages