当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.configure方法代码示例

本文整理汇总了Python中pyrtos.models.meta.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyrtos.models.meta.DBSession的用法示例。


在下文中一共展示了DBSession.configure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _initTestingDB

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import configure [as 别名]
def _initTestingDB(makeuser=False):
    engine = create_engine('sqlite://')
    Base.metadata.create_all(engine)
    DBSession.configure(bind=engine)
    if makeuser:
        m = BPM()
        hashed = m.encode(u'1234567')
        with transaction.manager:
            user = User(email=u'[email protected]',
                        password=hashed,
                        group='admin',
                        )
            DBSession.add(user)
    return DBSession
开发者ID:plastboks,项目名称:Pyrtos,代码行数:16,代码来源:base.py

示例2: main

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)

    m = BPM()
    a_email = raw_input('Enter email for admin account: ')
    a_pw = getpass('Enter password for admin account: ')
    a_hashed = m.encode(a_pw)

    with transaction.manager:
        admin = User(
                        email=a_email,
                        password=a_hashed,
                        group='admin',
                    )
        DBSession.add(admin)
开发者ID:plastboks,项目名称:Pyrtos,代码行数:24,代码来源:initializedb.py

示例3: main

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import configure [as 别名]
def main(global_config, **settings):
    """
    Pyrtos base script. This is where everything is called.
    Below are some basic configuration settings.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    authenPol = AuthTktAuthenticationPolicy('somesecret',
                                            callback=groupfinder,
                                            hashalg='sha512')
    authorPol = ACLAuthorizationPolicy()
    sess_factory = UnencryptedCookieSessionFactoryConfig('someothersecret')

    config = Configurator(settings=settings,
                          authentication_policy=authenPol,
                          authorization_policy=authorPol,
                          root_factory='pyrtos.security.EntryFactory',
                          session_factory=sess_factory,)

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_request_method(can_i, 'can_i')

    """ Index route """
    config.add_route('index', '/')

    """ Auth routes """
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    """ Category routes """
    config.add_route('categories', '/categories')
    config.add_route('categories_archived', '/categories/archived')
    config.add_route('category_new', '/category/new')
    config.add_route('category_edit', '/category/edit/{id}')
    config.add_route('category_archive', '/category/archive/{id}')
    config.add_route('category_restore', '/category/restore/{id}')

    """ Tag routes """
    config.add_route('tags', '/tags')

    """ User routes """
    config.add_route('users', '/users')
    config.add_route('users_archived', '/users/archived')
    config.add_route('user_new', '/user/new')
    config.add_route('user_edit', '/user/edit/{id}')
    config.add_route('user_archive', '/user/archive/{id}')
    config.add_route('user_restore', '/user/restore/{id}')

    """ Creditor routes """
    config.add_route('creditors', '/creditors')
    config.add_route('creditors_archived', '/creditors/archived')
    config.add_route('creditor_new', '/creditor/new')
    config.add_route('creditor_edit', '/creditor/edit/{id}')
    config.add_route('creditor_archive', '/creditor/archive/{id}')
    config.add_route('creditor_restore', '/creditor/restore/{id}')

    """ Income routes """
    config.add_route('incomes', '/incomes')
    config.add_route('incomes_archived', '/incomes/archived')
    config.add_route('income_new', '/income/new')
    config.add_route('income_edit', '/income/edit/{id}')
    config.add_route('income_archive', '/income/archive/{id}')
    config.add_route('income_restore', '/income/restore/{id}')

    """ Expenditure routes """
    config.add_route('expenditures', '/expenditures')
    config.add_route('expenditures_private', '/expenditures/private')
    config.add_route('expenditures_archived', '/expenditures/archived')
    config.add_route('expenditure_new', '/expenditure/new')
    config.add_route('expenditure_edit', '/expenditure/edit/{id}')
    config.add_route('expenditure_archive', '/expenditure/archive/{id}')
    config.add_route('expenditure_restore', '/expenditure/restore/{id}')

    """ Invoice routes """
    config.add_route('invoices', '/invoices')
    config.add_route('invoices_archived', '/invoices/archived')
    config.add_route('invoices_search', '/invoices/search')
    config.add_route('invoice_new', '/invoice/new')
    config.add_route('invoice_edit', '/invoice/edit/{id}')
    config.add_route('invoice_quickpay', '/invoice/quickpay/{id}')
    config.add_route('invoice_archive', '/invoice/archive/{id}')
    config.add_route('invoice_restore', '/invoice/restore/{id}')

    """ File routes """
    config.add_route('files', '/files')
    config.add_route('files_archived', '/files/archived')
    config.add_route('file_new', '/file/new')
    config.add_route('file_download', '/file/download/{id}')

    config.scan()
    return config.make_wsgi_app()
开发者ID:plastboks,项目名称:Pyrtos,代码行数:95,代码来源:__init__.py

示例4: setUp

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import configure [as 别名]
 def setUp(self):
     Base.metadata.create_all(self.engine)
     DBSession.configure(bind=self.engine)
     self.session = DBSession
     self.config = testing.setUp()
开发者ID:plastboks,项目名称:Pyrtos,代码行数:7,代码来源:base.py


注:本文中的pyrtos.models.meta.DBSession.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。