-
Type: Bug
-
Resolution: Done
-
Priority: Trivial - P5
-
Affects Version/s: 2.4.2
-
Component/s: None
-
None
-
Environment:python 2.6 and 2.7, pymongo 2.4.2, mongod 2.2, osx and ubuntu
1 : import pymongo
2 : m=pymongo.Connection().test
3 : m.comment.count()
4 : m.connection.count()
test db has comment and connection collections
#3 succeeds, #4 crashes with
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pymongo/database.pyc in _call_(self, *args, **kwargs)
798 "call the '%s' method on a '%s' object it is "
799 "failing because no such method exists." % (
--> 800 self._name, self.connection.class.name_))
801
802
TypeError: 'Database' object is not callable. If you meant to call the 'count' method on a 'Connection' object it is failing because no such method exists.
Cause seems to be that 'connection' is a method in pymongo and conflicts with the valid 'connection' collection name.
Workaround is use bracket notation:
In [10]: m["connection"].count()
Out[10]: 22
A corner case with a workaround. Still, its a valid collection name and hopefully can be easily fixed.