Con l'imminente v0.6 Eve supporterà in modo nativo più istanze Mongo.
Puoi avere singoli endpoint API serviti da diverse istanze Mongo:
E/o puoi utilizzare un'istanza Mongo diversa a seconda dell'utente che accede al database:
Un'implementazione (molto) ingenua delle istanze utente, tratta dai documenti :
from eve.auth import BasicAuth
class MyBasicAuth(BasicAuth):
def check_auth(self, username, password, allowed_roles, resource, method):
if username == 'user1':
self.set_mongo_prefix('MONGO1')
elif username == 'user2':
self.set_mongo_prefix('MONGO2')
else:
# serve all other users from the default db.
self.set_mongo_prefix(None)
return username is not None and password == 'secret'
app = Eve(auth=MyBasicAuth)
app.run()
Inoltre:
Spero che questo soddisfi le tue esigenze. È attualmente in development
branch in modo da poter già sperimentare/giocare con esso.