hmarr / mongoengine

[Moved to mongoengine/mongoengine]
https://github.com/MongoEngine/mongoengine
MIT License
794 stars 20 forks source link

async backend and support #382

Open wpjunior opened 12 years ago

wpjunior commented 12 years ago

for integration in async apps. Libs: https://github.com/facebook/tornado https://github.com/bitly/asyncmongo

wpjunior commented 12 years ago

a prototype:


from mongoengine import *

set_backend('async')

class Animal(Document):
    nome = StringField()

def query_animals(animals, err):
    print animals

Animal.objects(nome__startswith="M",
               callback=query_animals,
               timeout=30)

def new_macaco(macaco, err):
    print macaco

Animal(nome="macaco").save(callback=new_macaco)

def distincts(nomes, err):
    print nomes

Animal.objects.distinct('nome', callback=distincts)

def delete_boi(err):
    print "deleted"

Animal.objects(nome="Boi").delete(callback=delete_boi)
wpjunior commented 12 years ago

a notice: https://jira.mongodb.org/browse/PYTHON-296