MongoDB adapter

66 views
Skip to first unread message

José Ricardo Borba

unread,
May 1, 2015, 9:58:13 PM5/1/15
to web...@googlegroups.com
Hi 4 All,

I'm new to mongoDB and still having some problems with a TIME field. When I set a TIME field in the table, fill the input field of a sqlform (only time is allowed) and send the data to table, all the record is inserted without any warning. But when I try to show in the sqlform, I receive a message:

<pre>
<code>
  Traceback (most recent call last):
  File "/home/xxx.../applications/ras/controllers/appadmin.py", line 269, in select
    *fields, limitby=(start, stop))
  File "/home/xxx.../gluon/packages/dal/pydal/objects.py", line 2026, in select
    return adapter.select(self.query,fields,attributes)
  File "/home/xxx.../gluon/packages/dal/pydal/adapters/mongo.py", line 353, in select
    result = processor(rows, fields, newnames, False)
  File "/home/xxx.../gluon/packages/dal/pydal/adapters/base.py", line 1596, in parse
    value = self.parse_value(value,ft,blob_decode)
  File "/home/xxx.../gluon/packages/dal/pydal/adapters/base.py", line 1450, in parse_value
    return self.parsemap[key](value,field_type)
  File "/home/xxx.../gluon/packages/dal/pydal/adapters/base.py", line 1472, in parse_time
    time_items = map(int,str(value)[:8].strip().split(':')[:3])
ValueError: invalid literal for int() with base 10: '2000-01-'
</code>
</pre>

Trying to understand what happened, I'm googled for some info, and found the Mongo adapter code (yes, I didn't tried in my own computer).

Reading the code (in pydal/adapters/mongo.py), I see a (possible) clue: The lines 148 to 163 is, in some way, weird for my reading. Maybe I misunderstood some point, but this

<pre>
<code>
t = datetime.time(0,0,0)
</code>
</pre>

is a formatter for a field type DATE, and this

<pre>
<code>
t = datetime.date(2000,1,1)
</code>
</pre>

is a formatter for a field type TIME ?

Best regards, and keep going the invaluable work with this framework.

--
José Ricardo Borba

Paolo Valleri

unread,
May 2, 2015, 3:23:01 AM5/2/15
to web...@googlegroups.com
Hi, try use the latest version of pydal, Mongo adapter has been recently updated to work with pymongo 3.0
However, I think this is a bug. Can you open a bug report on https://github.com/web2py/pydal

Paolo

José Ricardo Borba

unread,
May 2, 2015, 7:18:11 AM5/2/15
to web...@googlegroups.com
Paolo,

Thank you for you quickly response. But I'm working with the latest web2py/Pydal 2.10.4 (downloaded 2.10.3 and updated). I forgot to mention this. I'm sorry.

My second bet is that the parser of time (the time_itens above) need to be modified to work with time in mongo,

Still not knowing what is the correct "bug" (if there are one) to report.

Cheers,


--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
José Ricardo Borba

Paolo Valleri

unread,
May 2, 2015, 7:22:52 AM5/2/15
to web...@googlegroups.com

Open an issue to don't forget it,I'll fix it in the next few days

Paolo

You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/c8JpvzBHGhE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

José Ricardo Borba

unread,
May 2, 2015, 7:24:32 AM5/2/15
to web...@googlegroups.com
OK.
Thank you very much again.

Cheers.

Paolo Valleri

unread,
May 4, 2015, 8:39:48 AM5/4/15
to web...@googlegroups.com
It should be fixed in trunk

Paolo

Ron Chatterjee

unread,
May 4, 2015, 9:39:32 AM5/4/15
to web...@googlegroups.com
What is mongodb adapter? Where do I find that info?

José Ricardo Borba

unread,
May 7, 2015, 3:40:50 PM5/7/15
to web...@googlegroups.com
YAY !!!!

Everything is working FINE!
Thank you very much, Paolo, Massimo and others.

Cheers.
Reply all
Reply to author
Forward
0 new messages