hmarr/mongoengine — Issue #426: Feature request: pre_save for EmbeddedDocument fields
Author: danaki
Created: 2012-02-03 10:28:02+00:00
State: open

I have the following base model:
class TimeStamped:
created = DateTimeField()
modified = DateTimeField()

@classmethod
def pre_save(cls, sender, document, **kwargs):
now = datetime.datetime.now()
document.modified = now
if document.id is None:
document.created = now

However it doesn't work for

class Channel(EmbeddedDocument, TimeStamped):

Is it possible to implement pre_save for EmbeddedDocument or somehow achieve the goal?