def configure_libres(self, **cfg): """ Configures the libres integration and leaves two properties on the class: :libres_context: The libres context configured for the current application. :libres_registrye: The libres registry bound to the current application. With those two a scheduler can easily be created:: from libres import new_scheduler scheduler = new_scheduler( app.libres_context, 'test', 'Europe/Zurich' ) """ assert self.session_manager.bases, "Must be run after configure_dsn" self.session_manager.bases.append(ORMBase) self.libres_registry = create_default_registry() self.libres_context = self.libres_context_from_session_manager( self.libres_registry, self.session_manager )
def configure_libres(self, **cfg): """ Configures the libres integration and leaves two properties on the class: :libres_context: The libres context configured for the current application. :libres_registrye: The libres registry bound to the current application. With those two a scheduler can easily be created:: from libres import new_scheduler scheduler = new_scheduler( app.libres_context, 'test', 'Europe/Zurich' ) """ assert self.session_manager.bases, "Must be run after configure_dsn" self.session_manager.bases.append(ORMBase) self.libres_registry = create_default_registry() self.libres_context = self.libres_context_from_session_manager( self.libres_registry, self.session_manager)
def libres_context(session_manager): session_manager.bases.append(ORMBase) session_manager.set_current_schema('test_' + uuid4().hex) registry = create_default_registry() yield LibresIntegration.libres_context_from_session_manager( registry, session_manager)
def libres_context(session_manager): session_manager.bases.append(ORMBase) session_manager.set_current_schema('test_' + uuid4().hex) registry = create_default_registry() yield LibresIntegration.libres_context_from_session_manager( registry, session_manager )
def cli(ctx, dsn, schema): ctx.obj = {} mgr = SessionManager(dsn, base=Base) mgr.bases.append(ORMBase) mgr.set_current_schema(schema) ctx.obj['schema'] = schema ctx.obj['session_manager'] = mgr ctx.obj['session'] = mgr.session() ctx.obj['libres_registry'] = create_default_registry()
from __future__ import unicode_literals from libres.context.registry import create_default_registry from libres.db import new_scheduler registry = create_default_registry() __all__ = ['new_scheduler', 'registry']