MongoEngine / MongoEngine/mongoengine

Any plans for a new release? Also, suggestions for transaction API improvements

Open
#2,906 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

Hi there,

I noticed that the last feature release for mongoengine was back in 2024. The development branch has accumulated quite a few new features since then, especially around MongoDB transactions, which I'm really eager to use in my project.

Currently, I'm installing directly from GitHub to work around this, but it would be great if a new version could be officially released on PyPI. Are there any plans for a new release in the near future?

Regarding transactions:

run_in_transaction works great. However, sometimes I find it hard to use the with statement directly, and I end up writing something like this:

# Pseudo-code example
@app.before_request
def start_transaction():
    conn = get_connection()
    g.session = conn.start_session()
    g.session.start_transaction()
    _set_session(g.session)

@app.teardown_request
def teardown_transaction(exc):
    if not g.session:
        return
    try:
        if not exc:
            _commit_with_retry(g.session)
    finally:
        _clear_session()
        del g.session

This approach relies on underscore-prefixed methods, which feels a bit hacky and not ideal.
It would be much nicer if there were public methods like conn.start_transaction() and conn.commit_transaction() to handle this more cleanly.

Thanks for your time and for maintaining mongoengine!

(My English isn’t great, so this issue was polished with the help of AI—apologies for any awkwardness.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by reviewing the existing run_in_transaction API and the transaction flow using conn.start_session(), start_transaction(), _set_session(), _commit_with_retry(), and _clear_session(); completion would require an agreed public transaction API and corresponding validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.