Skip to content

PyMongo 3 compatibility #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ajdavis opened this issue Apr 16, 2015 · 8 comments
Closed

PyMongo 3 compatibility #207

ajdavis opened this issue Apr 16, 2015 · 8 comments

Comments

@ajdavis
Copy link

ajdavis commented Apr 16, 2015

"auto_start_request" option is gone, "max_pool_size" renamed to "maxPoolSize", "safe" is gone, "_connect" is renamed "connect".

ajdavis added a commit to ajdavis/mongodb-engine that referenced this issue Apr 16, 2015
"auto_start_request" option is gone, "max_pool_size" renamed to
"maxPoolSize", "safe" is gone, "_connect" is renamed "connect".
Closes issue django-nonrel#207.
ajdavis added a commit to ajdavis/mongodb-engine that referenced this issue Apr 16, 2015
@atuljain
Copy link

i am also getting errro while using syncdb , and i can't able to work with mongoDB , any help, how can i solve it

@ghost
Copy link

ghost commented May 2, 2015

I was following the instructions from this site and am now encountering issues I believe are related.
https://django-mongodb-engine.readthedocs.org/en/latest/topics/setup.html

(djangotest):~/develop/djangotest/djangotest$ ./manage.py syncdb
ConfigurationError: Unknown option auto_start_request
(djangotest):~/develop/djangotest/djangotest$ ./manage.py syncdb
ConfigurationError: Unknown option safe
(djangotest):~/develop/djangotest/djangotest$ ./manage.py syncdb
ConfigurationError: Unknown option _connect
(djangotest):~/develop/djangotest/djangotest$ ./manage.py syncdb
ConfigurationError: Unknown option max_pool_size
(djangotest):~/develop/djangotest/djangotest$ ./manage.py syncdb
Creating tables ...
TypeError: __init__() got an unexpected keyword argument 'fields'
Exception AttributeError: "'DebugCursor' object has no attribute '_Cursor__id'" in <bound method DebugCursor.__del__ of <django_mongodb_engine.utils.DebugCursor object at 0x7f693c021590>> ignored

while attempting to circumvent by modifying django_mongodb_engine/base.py:

        conn_options = dict(
            host=host,
            port=int(port),
#            max_pool_size=None,
            document_class=dict,
            tz_aware=False,
#            _connect=True,
#            auto_start_request=True,
#            safe=False
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 112, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/core/management/sql.py", line 216, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 185, in send
    response = receiver(signal=self, sender=sender, **named)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 93, in create_permissions
    'content_type', 'codename')[:1000000]:
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/db/models/query.py", line 96, in __iter__
    self._fetch_all()
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/db/models/query.py", line 857, in _fetch_all
    self._result_cache = list(self.iterator())
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django/db/models/query.py", line 1071, in iterator
    for row in self.query.get_compiler(self.db).results_iter():
  File "~/develop/djangotest/local/lib/python2.7/site-packages/djangotoolbox/db/basecompiler.py", line 380, in results_iter
    for entity in results:
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django_mongodb_engine/compiler.py", line 104, in fetch
    results = self.get_cursor()
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django_mongodb_engine/compiler.py", line 139, in get_cursor
    cursor = self.collection.find(self.mongo_query, fields=fields)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django_mongodb_engine/utils.py", line 75, in find
    return DebugCursor(self, self.collection, *args, **kwargs)
  File "~/develop/djangotest/local/lib/python2.7/site-packages/django_mongodb_engine/utils.py", line 100, in __init__
    super(DebugCursor, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'fields'
Exception AttributeError: "'DebugCursor' object has no attribute '_Cursor__id'" in <bound method DebugCursor.__del__ of <django_mongodb_engine.utils.DebugCursor object at 0x3097290>> ignored

Versions:
MongoDB 2.4.5
Python 2.7.5+
Django-1.5.11-py2.7
pymongo-3.0.1-py2.7
django_mongodb_engine-0.5.2-py2.7
djangotoolbox-1.6.2-py2.7

Is there something I'm missing?

@ajdavis
Copy link
Author

ajdavis commented May 2, 2015

Cursor's "fields" argument was renamed "projection" in PyMongo 3:

https://github.com/mongodb/mongo-python-driver/blob/3.0.1/pymongo/cursor.py#L101

The change was made to match the new CRUD API spec that unifies argument names among all MongoDB drivers (Java, C++, etc. etc.).

An irritating quirk of Python is that object destructors run, even if the constructor couldn't be called due to an argument error. So in this case the Cursor.__id attribute was never set because the constructor wasn't called, but the destructor tries to access it anyway.

Short story: once we deal with the test failures, part of upgrading django_mongodb_engine to PyMongo 3 will be replacing the "fields" argument name with "projection" when creating a Cursor.

@sreenathramu
Copy link

Exception AttributeError: "'DebugCursor' object has no attribute '_Cursor__id'"

Is there any way to clear the error?
Versions:
Pymongo-3.0.2
django_mongodb_engine-0.5.2-py2.7
djangotoolbox-1.6.2-py2.7

@jayachandp
Copy link

Try installing older stable version of Pymongo

@markunsworth
Copy link
Contributor

Yes. You need to fix your pymongo version to be

pymongo<3.0

There's a fix for this in #213

On Friday, June 19, 2015, jayachandp [email protected] wrote:

Try installing older stable version of Pymongo


Reply to this email directly or view it on GitHub
#207 (comment)
.

[image: Knowsis Ltd] http://www.knowsis.com/

Mark Unsworth / CTO
0772352910/ [email protected]

Knowsis Ltd Office: +44 (0) 203 286 6950
36 Lexington St, London, W1F 0LJ
http://www.knowsis.com

This e-mail message may contain confidential or legally privileged
information and is intended only for the use of the intended recipient(s).
Any unauthorized disclosure, dissemination, distribution, copying or the
taking of any action in reliance on the information herein is prohibited.
E-mails are not secure and cannot be guaranteed to be error free as they
can be intercepted, amended, or contain viruses. Anyone who communicates
with us by e-mail is deemed to have accepted these risks. Company Name is
not responsible for errors or omissions in this message and denies any
responsibility for any damage arising from the use of e-mail. Any opinion
and other statement contained in this message and any attachment are solely
those of the author and do not necessarily represent those of the company.

@markunsworth
Copy link
Contributor

You can close this one out now.

Fixed in #214

@ajdavis
Copy link
Author

ajdavis commented Jun 26, 2015

Thanks for picking this up Mark!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants