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


Python DBSession.add_all方法代码示例

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


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

示例1: test_nice_name_attribute_is_working_properly

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import add_all [as 别名]
    def test_nice_name_attribute_is_working_properly(self):
        """testing if the nice_name attribute is working properly
        """
        # for self.test_version
        self.assertEqual(self.test_version.naming_parents, [self.test_shot1, self.test_task1])

        # for a new version of a task
        task1 = Task(name="Test Task 1", project=self.test_project, status_list=self.test_task_status_list)

        task2 = Task(name="Test Task 2", parent=task1, status_list=self.test_task_status_list)

        task3 = Task(name="Test Task 3", parent=task2, status_list=self.test_task_status_list)
        DBSession.add_all([task1, task2, task3])
        DBSession.commit()

        version1 = Version(task=task3, take_name="Take1")
        DBSession.add(version1)
        DBSession.commit()

        self.assertEqual(
            version1.nice_name, "%s_%s_%s_%s" % (task1.nice_name, task2.nice_name, task3.nice_name, version1.take_name)
        )

        # for a an asset version
        asset_statuses = StatusList(
            target_entity_type="Asset", statuses=[self.test_status1, self.test_status2, self.test_status3]
        )
        character_type = Type(target_entity_type="Asset", name="Character", code="Char")
        asset1 = Asset(name="Asset1", code="Asset1", parent=task1, status_list=asset_statuses, type=character_type)
        version2 = Version(task=asset1)
        self.assertEqual(version2.nice_name, "%s_%s" % (asset1.nice_name, version2.take_name))

        # for a version of a task of a shot
        shot2 = Shot(name="SH002", code="SH002", parent=task3, status_list=self.test_shot_status_list)

        task4 = Task(name="Test Task 4", parent=shot2, status_list=self.test_task_status_list)

        version3 = Version(task=task4)

        self.assertEqual(version3.nice_name, "%s_%s_%s" % (shot2.nice_name, task4.nice_name, version3.take_name))

        # for an asset of a shot
        asset2 = Asset(name="Asset2", code="Asset2", parent=shot2, status_list=asset_statuses, type=character_type)
        version4 = Version(task=asset2)
        self.assertEqual(version4.nice_name, "%s_%s" % (asset2.nice_name, version4.take_name))
开发者ID:noflame,项目名称:stalker,代码行数:47,代码来源:test_version.py

示例2: accept

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import add_all [as 别名]

#.........这里部分代码省略.........
            status_cmpl = Status.query.filter(Status.code == 'CMPL').first()

            forced_status_type = \
                Type.query.filter(Type.name == 'Forced Status').first()

            # also create a Note
            from stalker import Note
            new_note = Note(
                content='%s has changed this task status to Completed' %
                        resource.name,
                type=forced_status_type,
                created_by=self.logged_in_user,
                date_created=utc_now
            )
            DBSession.add(new_note)
            task.notes.append(new_note)
            task.status = status_cmpl
            DBSession.commit()

        elif submit_to_final_review:
            # clip the Task timing to current time logs
            from stalker import Task
            schedule_timing, schedule_unit = \
                task.least_meaningful_time_unit(
                    task.total_logged_seconds
                )

            task.schedule_timing = schedule_timing
            task.schedule_unit = schedule_unit
            DBSession.add(task)

            try:
                DBSession.commit()
            except IntegrityError as e:
                QtWidgets.QMessageBox.critical(
                    self,
                    'Error',
                    'Database Error!!!'
                    '<br>'
                    '%s' % e
                )
                DBSession.rollback()
                return

            # request a review
            reviews = task.request_review()
            for review in reviews:
                review.created_by = review.updated_by = self.logged_in_user
                review.date_created = utc_now
                review.date_updated = utc_now
            DBSession.add_all(reviews)

            # and create a Note for the Task
            request_review_note_type = \
                Type.query\
                    .filter(Type.target_entity_type == 'Note')\
                    .filter(Type.name == 'Request Review')\
                    .first()

            from stalker import Note
            request_review_note = Note(
                type=request_review_note_type,
                created_by=self.logged_in_user,
                date_created=utc_now
            )
            DBSession.add(request_review_note)
            DBSession.add(task)
            task.notes.append(request_review_note)

            try:
                DBSession.commit()
            except IntegrityError as e:
                DBSession.rollback()
                QtWidgets.QMessageBox.critical(
                    self,
                    'Error',
                    'Database Error!!!'
                    '<br>'
                    '%s' % e
                )
                return

        # Fix statuses
        from anima import utils
        utils.fix_task_statuses(task)
        try:
            DBSession.commit()
        except IntegrityError as e:
            DBSession.rollback()
            QtWidgets.QMessageBox.critical(
                self,
                'Error',
                'Database Error!!!'
                '<br>'
                '%s' % e
            )
            return

        # if nothing bad happens close the dialog
        super(MainDialog, self).accept()
开发者ID:eoyilmaz,项目名称:anima,代码行数:104,代码来源:time_log_dialog.py

示例3: setUp

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import add_all [as 别名]
    def setUp(self):
        """setup the test
        """
        # setup a test database
        self.TEST_DATABASE_URI = "sqlite:///:memory:"
        db.setup()
        db.init()

        # need to have some test object for
        # a department
        self.test_department1 = Department(name="Test Department 1")
        self.test_department2 = Department(name="Test Department 2")
        self.test_department3 = Department(name="Test Department 3")

        DBSession.add_all([self.test_department1, self.test_department2, self.test_department3])

        # a couple of groups
        self.test_group1 = Group(name="Test Group 1")
        self.test_group2 = Group(name="Test Group 2")
        self.test_group3 = Group(name="Test Group 3")

        DBSession.add_all([self.test_group1, self.test_group2, self.test_group3])

        # a couple of statuses
        self.test_status1 = Status(name="Completed", code="CMPLT")
        self.test_status2 = Status(name="Work In Progress", code="WIP")
        self.test_status3 = Status(name="Waiting To Start", code="WTS")
        self.test_status4 = Status(name="Pending Review", code="PRev")

        DBSession.add_all([self.test_status1, self.test_status2, self.test_status3, self.test_status4])

        # a project status list
        self.project_status_list = StatusList(
            name="Project Status List",
            statuses=[self.test_status1, self.test_status2, self.test_status3, self.test_status4],
            target_entity_type=Project,
        )

        # a repository type
        self.test_repository_type = Type(name="Test", code="test", target_entity_type=Repository)

        # a repository
        self.test_repository = Repository(name="Test Repository", type=self.test_repository_type)

        # a project type
        self.commercial_project_type = Type(name="Commercial Project", code="comm", target_entity_type=Project)

        # a couple of projects
        self.test_project1 = Project(
            name="Test Project 1",
            code="tp1",
            status_list=self.project_status_list,
            type=self.commercial_project_type,
            repository=self.test_repository,
        )

        self.test_project2 = Project(
            name="Test Project 2",
            code="tp2",
            status_list=self.project_status_list,
            type=self.commercial_project_type,
            repository=self.test_repository,
        )

        self.test_project3 = Project(
            name="Test Project 3",
            code="tp3",
            status_list=self.project_status_list,
            type=self.commercial_project_type,
            repository=self.test_repository,
        )

        DBSession.add_all([self.test_project1, self.test_project2, self.test_project3])

        # a task status list
        self.task_status_list = StatusList.query.filter_by(target_entity_type="Task").first()

        # a couple of tasks
        self.test_task1 = Task(name="Test Task 1", status_list=self.task_status_list, project=self.test_project1)

        self.test_task2 = Task(name="Test Task 2", status_list=self.task_status_list, project=self.test_project1)

        self.test_task3 = Task(name="Test Task 3", status_list=self.task_status_list, project=self.test_project2)

        self.test_task4 = Task(name="Test Task 4", status_list=self.task_status_list, project=self.test_project3)

        DBSession.add_all([self.test_task1, self.test_task2, self.test_task3, self.test_task4])

        # for task1
        self.test_version1 = Version(task=self.test_task1, full_path="some/path")
        DBSession.add(self.test_version1)

        self.test_version2 = Version(task=self.test_task1, full_path="some/path")
        DBSession.add(self.test_version2)

        self.test_version3 = Version(task=self.test_task1, full_path="some/path")
        DBSession.add(self.test_version3)

        # for task2
        self.test_version4 = Version(task=self.test_task2, full_path="some/path")
#.........这里部分代码省略.........
开发者ID:GreenEminence,项目名称:stalker,代码行数:103,代码来源:test_user.py

示例4: Task

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import add_all [as 别名]
    name="Task Statuses",
    statuses=[status1, status2],
    target_entity_type=Task
)

new_task = Task(
    name="Task 1",
    resources=[new_user1],
    parent=new_asset1,
    status_list=task_status_list
)

new_task = Task(
    name="Task 2",
    resources=[new_user2],
    parent=new_asset2,
    status_list=task_status_list
)

#new_project.assets
#new_asset.project
#new_project
#new_project.assets.append(new_asset)
#new_project.assets

DBSession.add_all([new_project1, new_project2])
DBSession.commit()

# uses are now assigned to projects
assert new_project1.users == []
开发者ID:2008chny,项目名称:stalker,代码行数:32,代码来源:test_generic_db.py

示例5: setUp

# 需要导入模块: from stalker.db.session import DBSession [as 别名]
# 或者: from stalker.db.session.DBSession import add_all [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


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