def main(argv=sys.argv): if len(argv) < 2: usage(argv) config_uri = argv[1] options = parse_vars(argv[2:]) setup_logging(config_uri) settings = get_appsettings(config_uri, options=options) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: model = RasPi() model.uuid = '11:22:33:44:55:66' model.description = "Testing Pi" model.url = "http://www.facebook.com" model.orientation = 0 model.browser = True model.lastseen = datetime.now() DBSession.add(model) tag = Tags() tag.uuid = '11:22:33:44:55:66' tag.tag = 'test' DBSession.add(tag) User = UserModel() User.email = '*****@*****.**' User.AccessLevel = 2 DBSession.add(User) DBSession.flush()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ NotSoSecret = 'CIeUz0RK8fjRq1wJSrID' authn_policy = AuthTktAuthenticationPolicy(NotSoSecret, callback=groupfinder, hashalg='sha512') authz_policy = ACLAuthorizationPolicy() session_factory = SignedCookieSessionFactory(NotSoSecret) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine config = Configurator(settings=settings, root_factory=Root) config.set_authentication_policy(authn_policy) config.set_authorization_policy(authz_policy) config.include('velruse.providers.google_oauth2') config.set_session_factory(session_factory) config.add_google_oauth2_login_from_settings(prefix='velruse.google.') config.include('cornice') config.include('pyramid_mako') config.add_static_view('static', 'static', cache_max_age=3600) config.add_static_view('client_agent', 'client_agent', cache_max_age=3600) config.add_route('home', '/') config.add_route('tagged', '/tagged/{tags}') config.add_route('users', '/users') config.add_route('logout', '/logout') config.add_route('redirectme', '/go/{uid}') config.add_route('provision', '/provision') config.add_route('logs', '/logs/{uuid}') config.add_route('wall', '/wall/{tags}') config.add_request_method(LookupUser, 'user', reify=True) config.scan() return config.make_wsgi_app()
def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine('sqlite://') from pi_director.models.models import ( Base, RasPi, ) DBSession.configure(bind=engine)
def main(argv=sys.argv): if len(argv) < 2: usage(argv) config_uri = argv[1] options = parse_vars(argv[2:]) setup_logging(config_uri) settings = get_appsettings(config_uri, options=options) engine = engine_from_config(settings, "sqlalchemy.") DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: model = RasPi(uuid="default", url="http://www.facebook.com") DBSession.add(model)
def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine('sqlite://') from pi_director.models.models import ( Base, RasPi, ) DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: model = RasPi(name='one', value=55) DBSession.add(model)