Skip to content

Implement lazy assignment for Reverse Delete Rules (aka the NotRegistered exception) #2764

Open
@combscCode

Description

@combscCode

MongoEngine will throw a NotRegistered exception when a user tries to register a delete rule on a Document that hasn't been defined yet. This is because the delete rule is stored directly on the Document class, so attempting to access the Document through get_document throws an exception. Rather than immediately throwing an exception, MongoEngine should just store the delete rule and lazily assign it to the Document once it is defined.

Fixing this issue will allow users to define bi-directional delete rules (this can currently be done by defining delete rules at runtime, but this behavior is not documented well). It also decouples delete rules from import ordering, which created a problem for my project that uses mongoengine.

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