Skip to content

simple_webapp_using_mongodb.py: TypeError("__init__() got an unexpected keyword argument 'fields'",) #91

@bobeina

Description

@bobeina

I got this error when I accessed /admin page.
Solution first:
In method __iter() of class MongoTable, mongodb_backend.py:
Replace line 53
r = self._coll.find(fields=[self.key_name,])
with

r = self._coll.find( { self.key_name : { '$exists': True } } )

Here is traceback:

Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/bottle.py", line 862, in _handle
return route.call(*_args)
File "/usr/lib64/python2.7/site-packages/bottle.py", line 1732, in wrapper
rv = callback(_a, *_ka)
File "/usr/lib64/python2.7/site-packages/bottle.py", line 3615, in wrapper
result = func(_args, **kwargs)
File "blog.py", line 169, in admin
for i in tu:
File "/usr/lib64/python2.7/site-packages/cork/cork.py", line 314, in list_users
for un in sorted(self._store.users):
File "/usr/lib64/python2.7/site-packages/cork/mongodb_backend.py", line 53, in iter
r = self._coll.find(fields=[self._key_name,]) #debug
File "/usr/lib64/python2.7/site-packages/pymongo/collection.py", line 929, in find
return Cursor(self, _args, *_kwargs)
TypeError: init() got an unexpected keyword argument 'fields'

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions