MongoEngine / MongoEngine/mongoengine
Implement lazy assignment for Reverse Delete Rules (aka the NotRegistered exception)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing delete-rule registration on the Document class and the get_document lookup, focusing on where NotRegistered is raised for an undefined Document. Done means the rule is retained until that Document is defined, supports bidirectional rules, and no longer depends on import order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100