Skip to content

Signals pre_save is triggered on the parent document not the embedded one #1720

@charli-polo

Description

@charli-polo

Hi there,

I tried to auto update a timestamp on a EmbeddedDocument, but when calling save() on the EmbeddedDocument document, the signals receive an instance of the parent document...

Is this a bug or I am doing something wrong ?

class Item(db.EmbeddedDocument):
    url = db.StringField(primary_key=True)
    title = db.StringField()
    modified = db.DateTimeField()

class Search(db.Document):
    name = db.StringField(required=True)
    items = db.EmbeddedDocumentListField(Item)
 
def update_modified(sender, document):
    logging.warning(sender)
    logging.warning(document)

signals.pre_save.connect(update_modified)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions