Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7560511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:55:21+00:00 2026-05-30T12:55:21+00:00

Anyone has experiences with MongoKit, MongoEngine or Flask-MongoAlchemy for Flask? Which one do you

  • 0

Anyone has experiences with MongoKit, MongoEngine or Flask-MongoAlchemy for Flask?

Which one do you prefer? Positive or negative experiences?. Too many options for a Flask-Newbie.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:55:23+00:00Added an answer on May 30, 2026 at 12:55 pm

    I have invested a lot of time evaluating the popular Python ORMs for MongoDB. This was an exhaustive exercise, as I really wanted to pick one.

    My conclusion is that an ORM removes the fun out of MongoDB. None feels natural, they impose restrictions similar to the ones which made me move away from relational databases in the first place.

    Again, I really wanted to use an ORM, but now I am convinced that using pymongo directly is the way to go. Now, I follow a pattern which embraces MongoDB, pymongo, and Python.

    A Resource Oriented Architecture leads to very natural representations. For instance, take the following User resource:

    from werkzeug.wrappers import Response
    from werkzeug.exceptions import NotFound
    
    Users = pymongo.Connection("localhost", 27017)["mydb"]["users"]
    
    
    class User(Resource):
    
        def GET(self, request, username):
            spec = {
                "_id": username,
                "_meta.active": True
            }
            # this is a simple call to pymongo - really, do
            # we need anything else?
            doc = Users.find_one(spec)
            if not doc:
                return NotFound(username)
            payload, mimetype = representation(doc, request.accept)
            return Response(payload, mimetype=mimetype, status=200)
    
        def PUT(self, request, username):
            spec = {
                "_id": username,
                "_meta.active": True
            }
            operation = {
                "$set": request.json,
            }
            # this call to pymongo will return the updated document (implies safe=True)
            doc = Users.update(spec, operation, new=True)
            if not doc:
                return NotFound(username)
            payload, mimetype = representation(doc, request.accept)
            return Response(payload, mimetype=mimetype, status=200)
    

    The Resource base class looks like

    class Resource(object):
    
        def GET(self, request, **kwargs):
            return NotImplemented()
    
        def HEAD(self, request, **kwargs):
            return NotImplemented()
    
        def POST(self, request, **kwargs):
            return NotImplemented()
    
        def DELETE(self, request, **kwargs):
            return NotImplemented()
    
        def PUT(self, request, **kwargs):
            return NotImplemented()
    
        def __call__(self, request, **kwargs):
            handler = getattr(self, request.method)
            return handler(request, **kwargs)
    

    Notice that I use the WSGI spec directly, and leverage Werkzeug where possible (by the way, I think that Flask adds an unnecessary complication to Werkzeug).

    The function representation takes the request’s Accept headers, and produces a suitable representation (for example, application/json, or text/html). It is not difficult to implement. It also adds the Last-Modified header.

    Of course, your input needs to be sanitized, and the code, as presented, will not work (I mean it as an example, but it is not difficult to understand my point).

    Again, I tried everything, but this architecture made my code flexible, simple, and extensible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read somewhere that snprintf is faster than ostringstream. Has anyone has any experiences
Has anyone had any experiences developing large Java applications using GNU gettext for internationalization?
Has anyone had the same experiences with jQuery AJAX and the beforeSend property? Any
Has anyone built a website with IronPython and ASP.NET. What were your experiences and
Not really a question but I'm looking for comments/suggestions from anyone who has experiences
Has anyone tried using uWSGI with Cherokee? Can you share your experiences and what
Anyone has experiences about interfacing with multimedia [or Fn Function] keys in Java? There
Has anyone had any experiences with Caliburn and the DevExpress NavBarControl. I am attempting
I am wondering if anyone has experience working on Django projects in a small
I am using IIS 7.0 + Windows Server 2008. Anyone has experience to configure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.