Moved pre_save after validation and determination of creation state; added pre_save_validation where pre_save had been.
This commit is contained in:
parent
c5ce96c391
commit
04592c876b
@ -195,7 +195,7 @@ class Document(BaseDocument):
|
||||
the cascade save using cascade_kwargs which overwrites the
|
||||
existing kwargs with custom values
|
||||
"""
|
||||
signals.pre_save.send(self.__class__, document=self)
|
||||
signals.pre_save_validation.send(self.__class__, document=self)
|
||||
|
||||
if validate:
|
||||
self.validate(clean=clean)
|
||||
@ -206,7 +206,9 @@ class Document(BaseDocument):
|
||||
doc = self.to_mongo()
|
||||
|
||||
created = ('_id' not in doc or self._created or force_insert)
|
||||
|
||||
|
||||
signals.pre_save.send(self.__class__, document=self, created=created)
|
||||
|
||||
try:
|
||||
collection = self._get_collection()
|
||||
if created:
|
||||
|
@ -38,6 +38,7 @@ _signals = Namespace()
|
||||
|
||||
pre_init = _signals.signal('pre_init')
|
||||
post_init = _signals.signal('post_init')
|
||||
pre_save_validation = _signals.signal('pre_save_validation')
|
||||
pre_save = _signals.signal('pre_save')
|
||||
post_save = _signals.signal('post_save')
|
||||
pre_delete = _signals.signal('pre_delete')
|
||||
|
Loading…
x
Reference in New Issue
Block a user