本文整理汇总了Python中pi_director.models.models.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pi_director.models.models.DBSession
的用法示例。
在下文中一共展示了DBSession.configure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pi_director.models.models import DBSession [as 别名]
# 或者: from pi_director.models.models.DBSession import configure [as 别名]
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 = '[email protected]'
User.AccessLevel = 2
DBSession.add(User)
DBSession.flush()
示例2: main
# 需要导入模块: from pi_director.models.models import DBSession [as 别名]
# 或者: from pi_director.models.models.DBSession import configure [as 别名]
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()
示例3: setUp
# 需要导入模块: from pi_director.models.models import DBSession [as 别名]
# 或者: from pi_director.models.models.DBSession import configure [as 别名]
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)
示例4: main
# 需要导入模块: from pi_director.models.models import DBSession [as 别名]
# 或者: from pi_director.models.models.DBSession import configure [as 别名]
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)