findOne not a function on Collection object

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      Ubuntu 9.10 (64-bit), python 2.6.4, pymongo 1.4
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I believe this behaviour is strange:

      >>> import pymongo
      >>> conn = pymongo.Connection()
      >>> conn.foo.bar.find
      <bound method Collection.find of Collection(Database(Connection('localhost', 27017), u'foo'), u'bar')>
      >>> conn.foo.bar.findOne
      Collection(Database(Connection('localhost', 27017), u'foo'), u'bar.findOne')
      >>> conn.foo.bar.findOne()
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.6/dist-packages/pymongo/collection.py", line 774, in _call_
      self.__name.split(".")[-1])
      TypeError: 'Collection' object is not callable. If you meant to call the 'findOne' method on a 'Collection' object it is failing because no such method exists.

      Why is the findOne function not callable?

            Assignee:
            Unassigned
            Reporter:
            Milan Cermak
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: