Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

User.save() and User.validate() #212

Open
Winnetou opened this issue Nov 23, 2014 · 1 comment
Open

User.save() and User.validate() #212

Winnetou opened this issue Nov 23, 2014 · 1 comment

Comments

@Winnetou
Copy link
Contributor

In the mongokit.auth.User class '_id' and 'login' meant to be the same.
In [1]: from mongokit.auth import User
In [2]: me = User()
In [3]: me.login, me.email, me.password = 'Winnetou', 'mieszko.chowaniec@gmail.com', 'supersecret'
In [4]: me
Out [4]:
{'_id': 'Winnetou',
'user': {'email': 'mieszko.chowaniec@gmail.com',
'login': 'Winnetou',
'password': u'24f1ae1bd48d66a899a0929ad94643f4ac3d395276ee5135bacea9ee3f1a2746b2660b2f0421cd3f'}}

In [5]: me.validate()


InvalidDocument Traceback (most recent call last)
in ()
--> 1 me.validate()

/usr/local/lib/python2.7/dist-packages/mongokit/document.pyc in validate(self, auto_migrate)
227 # found when validating at init with autorefs
228 self._make_reference(self, self.structure)
--> 229 size = self.get_size()
230 (size_limit, size_limit_str) = self._get_size_limit()
231

/usr/local/lib/python2.7/dist-packages/mongokit/document.pyc in get_size(self)
261 except:
262 self._process_custom_type('bson', self, self.structure)
--> 263 size = len(BSON.encode(self))
264 self._process_custom_type('python', self, self.structure)
265 return size

/usr/local/lib/python2.7/dist-packages/bson/init.pyc in encode(cls, document, check_keys, uuid_subtype)
588 .. versionadded:: 1.9
589 """
--> 590 return cls(_dict_to_bson(document, check_keys, uuid_subtype))
591
592 def decode(self, as_class=dict,

InvalidDocument: Cannot encode object: {'login': 'Winnetou', 'password': u'24f1ae1bd48d66a899a0929ad94643f4ac3d395276ee5135bacea9ee3f1a2746b2660b2f0421cd3f', 'email': 'mieszko.chowaniec@gmail.com'}

In [6]: me.save()


InvalidDocument Traceback (most recent call last)
in ()
-->1 me.save()

/usr/local/lib/python2.7/dist-packages/mongokit/auth.py in save(self, _args, *_kwargs)
97 def save(self, _args, *_kwargs):
98 assert self['_id'] == self['user']['login']
---> 99 super(User, self).save(_args, *_kwargs)

/usr/local/lib/python2.7/dist-packages/mongokit/document.pyc in save(self, uuid, validate, safe, _args, *_kwargs)
418 """
419 if validate is True or (validate is None and self.skip_validation is False):
--> 420 self.validate(auto_migrate=False)
421 else:
422 if self.use_autorefs:

/usr/local/lib/python2.7/dist-packages/mongokit/document.pyc in validate(self, auto_migrate)
227 # found when validating at init with autorefs
228 self._make_reference(self, self.structure)
--> 229 size = self.get_size()
230 (size_limit, size_limit_str) = self._get_size_limit()
231

/usr/local/lib/python2.7/dist-packages/mongokit/document.pyc in get_size(self)
261 except:
262 self._process_custom_type('bson', self, self.structure)
--> 263 size = len(BSON.encode(self))
264 self._process_custom_type('python', self, self.structure)
265 return size

/usr/local/lib/python2.7/dist-packages/bson/init.pyc in encode(cls, document, check_keys, uuid_subtype)
588 .. versionadded:: 1.9
589 """
--> 590 return cls(_dict_to_bson(document, check_keys, uuid_subtype))
591
592 def decode(self, as_class=dict,

InvalidDocument: Cannot encode object: {'login': 'Winnetou', 'password': u'24f1ae1bd48d66a899a0929ad94643f4ac3d395276ee5135bacea9ee3f1a2746b2660b2f0421cd3f', 'email': 'mieszko.chowaniec@gmail.com'}

@Winnetou
Copy link
Contributor Author

Running the test_auth shows the same problem: cannot encode object.
It looks like it was never run before (?).

@Winnetou Winnetou reopened this Nov 24, 2014
Winnetou added a commit to Winnetou/mongokit that referenced this issue Nov 25, 2014
With reference to issue namlook#212, the following must me tested:
- dot notation 
- validate() method
- password hashes with dot notation and without
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant