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


Python DBSession.configure方法代码示例

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


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

示例1: setup

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import configure [as 别名]
def setup(settings=None):
    """Utility function that helps to connect the system to the given database.

    if the database is None then the it setups using the default database in
    the settings file.

    :param settings: This is a dictionary which has keys prefixed with
        "sqlalchemy" and shows the settings. The most important one is the
        engine. The default is None, and in this case it uses the settings from
        stalker.config.Config.database_engine_settings
    """

    if settings is None:
        settings = defaults.database_engine_settings
        logger.debug("no settings given, using the default: %s" % settings)

    logger.debug("settings: %s" % settings)
    # create engine
    engine = engine_from_config(settings, "sqlalchemy.")

    logger.debug("engine: %s" % engine)

    # create the Session class
    DBSession.remove()
    DBSession.configure(bind=engine, extension=None)

    # create the database
    logger.debug("creating the tables")
    Base.metadata.create_all(engine)

    # update defaults
    update_defaults_with_studio()
开发者ID:GreenEminence,项目名称:stalker,代码行数:34,代码来源:__init__.py

示例2: setup

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import configure [as 别名]
def setup(settings=None):
    """Utility function that helps to connect the system to the given database.

    if the database is None then the it setups using the default database in
    the settings file.

    :param settings: This is a dictionary which has keys prefixed with
        "sqlalchemy" and shows the settings. The most important one is the
        engine. The default is None, and in this case it uses the settings from
        stalker.config.Config.database_engine_settings
    """

    if settings is None:
        settings = defaults.database_engine_settings
        logger.debug('no settings given, using the default: %s' % settings)

    logger.debug("settings: %s" % settings)
    # create engine
    engine = engine_from_config(settings, 'sqlalchemy.')

    logger.debug('engine: %s' % engine)

    # create the Session class
    DBSession.remove()
    DBSession.configure(
        bind=engine,
        extension=None
    )

    # check alembic versions of the database
    # and raise an error if it is not matching with the system
    check_alembic_version()

    # create the database
    logger.debug("creating the tables")
    Base.metadata.create_all(engine)

    # update defaults
    update_defaults_with_studio()

    # create repo env variables
    create_repo_vars()
开发者ID:Industriromantik,项目名称:stalker,代码行数:44,代码来源:__init__.py

示例3: Status

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import configure [as 别名]
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

from stalker import db, User
from stalker.models.asset import Asset
from stalker.models.project import Project
from stalker.models.repository import Repository
from stalker.db.session import DBSession
from stalker.models.status import Status, StatusList
from stalker.models.task import Task
from stalker.models.type import Type

DBSession.remove()
DBSession.configure(extension=None)
db.setup()

status1 = Status(name="Complete", code="CMPLT")
status2 = Status(name="Pending Review", code="PRev")

repo1 = Repository(name="TestRepo")

project_status_list = StatusList(
    name="test",
    target_entity_type=Project,
    statuses=[status1]
)

project_type = Type(
    name="test",
开发者ID:2008chny,项目名称:stalker,代码行数:33,代码来源:test_generic_db.py

示例4: setUp

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import configure [as 别名]
    def setUp(self):
        """setup the test
        """
        self.config = testing.setUp()
        db.setup({'sqlalchemy.url': 'sqlite:///:memory:'})

        DBSession.configure(extension=ZopeTransactionExtension())

        with transaction.manager:
            self.test_repo = Repository(
                name='Test Repository',
                linux_path=tempfile.mkdtemp(),
                windows_path=tempfile.mkdtemp(),
                osx_path=tempfile.mkdtemp()
            )
            DBSession.add(self.test_repo)

            self.status1 = Status(name='Status1', code='STS1')
            self.status2 = Status(name='Status2', code='STS2')
            self.status3 = Status(name='Status3', code='STS3')
            self.status4 = Status(name='Status4', code='STS4')
            self.status5 = Status(name='Status5', code='STS5')
            DBSession.add_all([self.status1, self.status2, self.status3,
                               self.status4, self.status5])

            self.test_project_status_list = StatusList(
                name='Project Statuses',
                statuses=[self.status1, self.status2, self.status3, self.status4,
                          self.status5],
                target_entity_type='Project'
            )
            DBSession.add(self.test_project_status_list)

            self.test_task_status_list = StatusList(
                name='Task Statuses',
                statuses=[self.status1, self.status2, self.status3, self.status4,
                          self.status5],
                target_entity_type='Task'
            )
            DBSession.add(self.test_task_status_list)

            self.test_version_status_list = StatusList(
                name='Version Statuses',
                statuses=[self.status1, self.status2, self.status3, self.status4,
                          self.status5],
                target_entity_type='Version'
            )
            DBSession.add(self.test_task_status_list)

            # create a project
            self.test_project = Project(
                name='Test Project',
                code='TP',
                repository=self.test_repo,
                status_list=self.test_project_status_list
            )
            DBSession.add(self.test_project)

            # create a task
            self.test_task = Task(
                project=self.test_project,
                name='Test Task',
                status_list=self.test_task_status_list
            )
            DBSession.add(self.test_task)

            # create a test version
            self.test_version = Version(
                task=self.test_task,
                status_list=self.test_version_status_list
            )
            DBSession.add(self.test_version)

        DBSession.add_all([
            self.test_project, self.test_project_status_list,
            self.test_repo, self.test_task, self.test_task_status_list,
            self.test_version
        ])
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:80,代码来源:test_version.py

示例5: tearDownClass

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import configure [as 别名]
 def tearDownClass(cls):
     """cleanup the test in class level
     """
     DBSession.remove()
     DBSession.configure()
开发者ID:2008chny,项目名称:stalker,代码行数:7,代码来源:test_aclMixin.py

示例6: setUpClass

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import configure [as 别名]
 def setUpClass(cls):
     """setup the test in class level
     """
     DBSession.remove()
     DBSession.configure()
开发者ID:2008chny,项目名称:stalker,代码行数:7,代码来源:test_aclMixin.py


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