couchdb sample: AttributeError: 'Server' object has no attribute 'commit'

410 views
Skip to first unread message

David Watson

unread,
Jan 5, 2011, 9:21:34 PM1/5/11
to web2py-users
Hello,

I am running CouchDBX 1.0.1 on Mac OS X 10.6 with couchdb-python
version 0.8. I am using the following code in db.py:

db=DAL('couchdb://127.0.0.1:5984')
db.define_table('person',Field('name'))
id=db.person.insert(name='Jim')
print id
row=db.person(id)
print row
print db(db.person.id==id).update(name="john")
print db.person(id)
del db.person[id]

However, when the code executes, it tries to call commit and dies. See
the traceback below. I realize that this support is experimental but I
wasn't sure if there was something I was doing wrong. I'm running hg
clones of trunk for both web2py and couchdb-python.

Thanks,
David

VERSION
web2py™ Version 1.91.6 (2011-01-04 15:55:30)
Python Python 2.6.1: /usr/bin/python

TRACEBACK

Traceback (most recent call last):
File "/Users/david/web2py/gluon/main.py", line 466, in wsgibase
BaseAdapter.close_all_instances(BaseAdapter.commit)
File "/Users/david/web2py/gluon/dal.py", line 272, in
close_all_instances
action(instance)
File "/Users/david/web2py/gluon/dal.py", line 1036, in commit
return self.connection.commit()
AttributeError: 'Server' object has no attribute 'commit'

mdipierro

unread,
Jan 5, 2011, 11:41:06 PM1/5/11
to web2py-users
this should now be fixed.please try.

David Watson

unread,
Jan 5, 2011, 11:59:26 PM1/5/11
to web2py-users
Hi Massimo,

I updated and now it fails with a similar exception on close:

Traceback (most recent call last):
File "/Users/david/web2py/gluon/main.py", line 466, in wsgibase
BaseAdapter.close_all_instances('commit')
File "/Users/david/web2py/gluon/dal.py", line 283, in
close_all_instances
instance.connection.close()
AttributeError: 'Server' object has no attribute 'close'

Thanks,
David

David Marko

unread,
Jan 6, 2011, 2:23:12 AM1/6/11
to web...@googlegroups.com
I have the same problem here.

Whats more with latest trunk I cant open http://127.0.0.1:8000/welcome/default/index . It raises:
Traceback (most recent call last
):
File "c:\java\web2py\gluon\restricted.py", line 188, in restricted
exec ccode in environment
File "c:/java/web2py/applications/welcome/models/db.py", line 42, in <module>
auth.define_tables() # creates all needed tables
File "c:\java\web2py\gluon\tools.py", line 1173, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)')
File "c:\java\web2py\gluon\dal.py", line 3431, in define_table
polymodel=polymodel)
File "c:\java\web2py\gluon\dal.py", line 468, in create_table
not_null = self.NOT_NULL(field.default,field.type)
File "c:\java\web2py\gluon\dal.py", line 665, in NOT_NULL
return 'NOT NULL DEFAULT %s' % self.represent(default,field_type)
File "c:\java\web2py\gluon\dal.py", line 1087, in represent
r = self.represent_exceptions(self,obj,fieldtype)
TypeError: represent_exceptions() takes exactly 3 arguments (4 given)

David Watson

unread,
Jan 6, 2011, 8:16:42 AM1/6/11
to web2py-users
I had the same crash as David Marko on the welcome app.

On Jan 6, 2:23 am, David Marko <dma...@tiscali.cz> wrote:
> I have the same problem here.
>
> Whats more with latest trunk I cant openhttp://127.0.0.1:8000/welcome/default/index. It raises:
>
> Traceback (most recent call last):
>   File "c:\java\web2py\gluon\restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "c:/java/web2py/applications/welcome/models/db.py" <http://127.0.0.1:8000/admin/default/edit/welcome/models/db.py>, line 42, in <module>

Massimo Di Pierro

unread,
Jan 6, 2011, 8:21:20 AM1/6/11
to web2py-users
pleas try again

Massimo Di Pierro

unread,
Jan 6, 2011, 8:21:58 AM1/6/11
to web2py-users
?

this line should not be in trunk:
r = self.represent_exceptions(self,obj,fieldtype)
it is

r = self.represent_exceptions(obj,fieldtype)

Massimo

On Jan 6, 1:23 am, David Marko <dma...@tiscali.cz> wrote:
> I have the same problem here.
>
> Whats more with latest trunk I cant openhttp://127.0.0.1:8000/welcome/default/index. It raises:
>
> Traceback (most recent call last):
>   File "c:\java\web2py\gluon\restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "c:/java/web2py/applications/welcome/models/db.py" <http://127.0.0.1:8000/admin/default/edit/welcome/models/db.py>, line 42, in <module>

dederocks

unread,
Jan 6, 2011, 8:44:38 AM1/6/11
to web2py-users
Works now -- thank you!

David Marko

unread,
Jan 6, 2011, 8:52:52 AM1/6/11
to web...@googlegroups.com
CouchDB si working for me as well. How can I get the original couchDb connection object from couchDB driver so can use another functions such as attachment handling etc.? 

Thanks!!
David
Reply all
Reply to author
Forward
0 new messages