added test for abstract document without pk creation and adapted behaviour

This commit is contained in:
mrigal
2015-04-16 14:33:16 +02:00
committed by Matthieu Rigal
parent 8909d1d144
commit 1862bcf867
3 changed files with 14 additions and 1 deletions

View File

@@ -184,7 +184,7 @@ class BaseDocument(object):
self__initialised = False
# Check if the user has created a new instance of a class
if (self._is_document and self__initialised
and self__created and name == self._meta['id_field']):
and self__created and name == self._meta.get('id_field')):
super(BaseDocument, self).__setattr__('_created', False)
super(BaseDocument, self).__setattr__(name, value)

View File

@@ -152,6 +152,8 @@ class Document(BaseDocument):
"""
def fget(self):
if not 'id_field' in self._meta:
return None
return getattr(self, self._meta['id_field'])
def fset(self, value):