Hi Massimo,

thanks for your reply. I don't think CouchDB has a datetime type but
the CouchDB-0.8 driver itself maps to and from iso string
representations '2007-04-01T15:30:00Z'. See Chapter 4 "Mapping CouchDB
documents to Python objects: couchdb.mapping" at
http://packages.python.org/CouchDB/mapping.html
Would it make sense for DAL to use couchdb.mapping directly?

I'd like to help but I don't understand dal well enough yet and in
particular the importance of the base class NoSQLAdapter. Does the
couchDB adapter really need to derive from it?

Best regards,
HC



On Oct 23, 5:48 pm, Massimo Di Pierro <[email protected]>
wrote:
> This is very helpful. I was expecting this problem. How are datetimes
> supposed to be stores in CouchDB?
>
> On Oct 22, 3:13 am, "H.C. v. Stockhausen" <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi
>
> > I am just testing the CouchDB Adapter and it fails when registering a
> > new user. I tired both w2py's default auth and janrain. The problem
> > appears to be the time_stamp field.
>
> > - w2py Version 1.99.2 (2011-09-26 06:55:33) stable
> > - driver CouchDB-0.8-py2.6.egg
>
> > Traceback
> > ========
> >   File "/home/hcvst/web2py/gluon/dal.py", line 3510, in insert
> >     ctable.save(values)
> >   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> > couchdb/client.py", line 407, in save
> >     _, _, data = func(body=doc, **options)
> >   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> > couchdb/http.py", line 405, in put_json
> >     status, headers, data = self.put(*a, **k)
> >   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> > couchdb/http.py", line 384, in put
> >     return self._request('PUT', path, body=body, headers=headers,
> > **params)
> >   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> > couchdb/http.py", line 419, in _request
> >     credentials=self.credentials)
> >   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> > couchdb/http.py", line 239, in request
> >     resp = _try_request_with_retries(iter(self.retry_delays))
> >   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> > couchdb/http.py", line 196, in _try_request_with_retries
> >     return _try_request()
> >   File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/
> > couchdb/http.py", line 222, in _try_request
> >     chunk = body.read(CHUNK_SIZE)
> > AttributeError: 'dict' object has no attribute 'read'
>
> > DAL CODE (dal.py at line 3510)
> > =========
> > def insert(self,table,fields):
> >         id = uuid2int(web2py_uuid())
> >         ctable = self.connection[table._tablename]
> >         values = dict((k.name,NoSQLAdapter.represent(self,v,k.type))
> > for k,v in fields)
> >         values['_id'] = str(id)
> >         ctable.save(values) # line 3510
>
> > DRIVER CODE (..egg/couchdb/http.py in _try_request at line 222)
> > ============
> >                 if body is not None:
> >                     if isinstance(body, str):
> >                         conn.sock.sendall(body)
> >                     else: # assume a file-like object and send in
> > chunks
> >                         while 1:
> >                             chunk = body.read(CHUNK_SIZE) # line 222
>
> > BODY VARIABLE
> > ==============
> > {'_id': '156782505411822007491552899341462059095', 'client_ip':
> > u'127.0.0.1', 'description': u'Group
> > 128304130898558275345572010972780625739 created', 'origin': u'auth',
> > 'time_stamp': datetime.datetime(2011, 10, 22, 3, 48, 48, 413381),
> > 'user_id': None}
>
> > The problem is probably that the BODY time_stamp attribute of type
> > datetime cannot be JSON serialized but I don't know dal.py well enough
> > to say what NoSQLAdapter.represent should return.
>
> > Best regards,
> > HC

Reply via email to