MongoTor

An asynchronous toolkit for accessing Mongo with Tornado
Download

MongoTor Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Other/Proprietary Li...
  • Price:
  • FREE
  • Publisher Name:
  • Marcel Nicolay
  • Publisher web site:
  • http://github.com/marcelnicolay/

MongoTor Tags


MongoTor Description

MongoTor (MONGO + TORnado) is an asynchronous toolkit for accessing Mongo with Tornado.Why not pymongo ?PyMongo is a recommended way to work with MongoDB in python, but isn't asynchronous and not run inside de tornado's ioloop. If you use pymongo you won't take the advantages of tornado.Why not asyncmongo?AsyncMongo is asynchronous library for accessing mongo with tornado.ioloop, but don't implement replica set, don't have an ORM, I don't like her connection pooling, is deficitary, and i don't trust in your tests.Besides, this project is not walking very well, or better, very fast. Exist a lot of issues and pull requests that aren't looked.I am very thankful to asyncmongo, i worked with he in some projects and he's been served as inspiration, but now, I am very excited to write my own library, more flexible, fast, secure and that will walking faster.Installingpip install mongotorUsingfrom mongotor.orm import Collectionfrom mongotor.orm.field import StringField, ObjectIdField, BooleanField, DateTimeFieldfrom mongotor.database import Databasefrom datetime import datetimeimport tornado.webfrom tornado import gen# A connection to the MongoDB database needs to be established before perform operations# A connection is stabilished using a Databse objectDatabase.connect(, 'asyncmongo_test')class User(Collection): __collection__ = "user" _id = ObjectIdField() name = StringField() active = BooleanField() created = DateTimeField()class Handler(tornado.web.RequestHandler): @tornado.web.asynchronous @gen.engine def get(self): user = User() user.name = "User name" user.active = True user.created = datetime.now() yield gen.Task(user.save) # update date user.name = "New name" yield gen.Task(user.update) # find one object user_found = yield gen.Task(User.objects.find_one, user._id) # find many objects new_user = User() new_user.name = "new user name" new_user.user.active = True new_user.created = datetime.now() users_actives = yield gen.Task(User.objects.find, {'active': True}) users_actives.active = False yield gen.Task(users_actives.save) # remove object yield gen.Task(user_found.remove)ContributingSend a pull request (preferred) or patches using git format-patch. Please, write unit and/or functional tests for your new feature.IssuesPlease report any issues via github issuesProduct's homepage


MongoTor Related Software