document new function

This commit is contained in:
Cayo Puigdefabregas 2020-10-16 16:30:53 +02:00
parent 7313f7cf73
commit 195c5265e4
1 changed files with 3 additions and 0 deletions

View File

@ -36,8 +36,11 @@ class Thing(db.Model):
self.created = kwargs.get('created', datetime.now(timezone.utc))
super().__init__(**kwargs)
def on_update_time(mapper, connection, thing_obj):
""" This function update the stamptime of field updated """
thing_obj.updated = datetime.now()
def update_timestamp(thing_obj):
""" This function launch a event than listen like a signal when some object is saved """
event.listen(thing_obj, 'before_update', on_update_time)