I'm encountering an error when uploading a CSV file when dates are involved 
in a computed field. Using sqlite, web2py version: 
2.8.2-stable+timestamp.2013.11.28.13.54.07 (also tested on 
2.9.5-stable+timestamp.2014.03.16.02.35.39).

E.g., consider the following table definition in a model:

db.define_table('POC2',
                Field('poc_date', 'date', required=True),
                Field('ten_days_before_poc_date', 'date', compute = lambda 
r: r['poc_date'] - datetime.timedelta(10))
                )


Now, use appadmin to manage the POC2 table and insert a new record. This 
works as expected. 

Now, try uploading the following CSV file and importing it into the table:

POC2.id,POC2.poc_date
1,2014-05-30

The following error appears:

unable to parse csv file

unsupported operand type(s) for -: 'str' and 'datetime.timedelta'



It appears that r['poc_date'] is passed to the lambda as a string when 
uploading via CSV, but as a date when going through appadmin. Is this the 
designed behavior, and is it documented anywhere? 

I can always test the datatype of r['poc_date'] and convert it to a 
datetime explicitly, but I don't want to make my code any messier than 
needed if I'm missing something regarding computed fields and CSV imports.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to