Skip to content

Can't pickle mongoengine.Document object #135

Closed
@Uznick

Description

@Uznick

Django from trunk, last version of mongoengine.

I insert the object into session and get exception on session autosaving:

On autosaving the session I get

Traceback:
File "/usr/local/var/pip/src/django/django/core/handlers/base.py" in get_response
  178.                 response = middleware_method(request, response)
File "/usr/local/var/pip/src/django/django/contrib/sessions/middleware.py" in process_response
  36.                 request.session.save()
File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mongoengine/django/sessions.py" in save
  49.         s.session_data = self.encode(self._get_session(no_load=must_create))
File "/usr/local/var/pip/src/django/django/contrib/sessions/backends/base.py" in encode
  93.         pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)
File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pymongo/collection.py" in __call__
  967.                         self.__name.split(".")[-1])

Exception Type: TypeError at /create/
Exception Value: 'Collection' object is not callable. If you meant to call the '__getnewargs__' method on a 'Collection' object it is failing because no such method exists.

The code my view.py is

toolbar = ToolbarStep2Form(request.POST)
new_toolbar = toolbar.save()
request.session['u_new_toolbar'] = new_toolbar

Form is created by django-mongoforms

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions