當前位置: 首頁>>代碼示例>>Python>>正文


Python Session.commit方法代碼示例

本文整理匯總了Python中pacemaker.model.meta.Session.commit方法的典型用法代碼示例。如果您正苦於以下問題:Python Session.commit方法的具體用法?Python Session.commit怎麽用?Python Session.commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pacemaker.model.meta.Session的用法示例。


在下文中一共展示了Session.commit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: delete

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def delete(self, id):
        """Deletes a selected project.
        """
        #TODO: check permisssions

        project = get_object_or_404(Project, id)

        comp_count = Session.query(Component).filter_by(project_id = id).count()
        if comp_count > 0:
            h.flash("Can't delete the project %s as it still \
                     contains components." % project.name)
            return redirect_to(controller='packages/product',
                               action='index',
                               id=project.product_id)

        name = project.name
        Session.begin()
        Session.delete(project)
        Session.commit()
        h.flash("The project <b>%s</b> has been deleted successfully" % \
                name)

        return redirect_to(controller='packages/product',
                           action='index',
                           id=project.product_id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:27,代碼來源:project.py

示例2: setUp

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
 def setUp(self):
     # TODO: this setup is better to move to common fixture
     Session.begin()
     for i in range(1, self.node_num + 1):
         product = Product("product%s" % i)
         for j in range(1, self.node_num + 1):
             if i == 2: # product without projects
                 continue
             project = Project("project%s.%s" % (i, j))
             for k in range(1, self.node_num + 1):
                 if j == 2: # project without components
                     continue
                 component = Component("component%s.%s.%s" % (i, j, k))
                 for l in range(1, self.node_num + 1):
                     if k == 2: # component without sources
                         continue
                     source = Source("source%s.%s.%s.%s" % (i, j, k, l))
                     for m in range(1, self.node_num + 1):
                         if l == 2: # source without binaries
                             continue
                         binary = Binary("binary%s.%s.%s.%s.%s" %
                                         (i, j, k, l, m))
                         source.binaries.append(binary)
                     component.sources.append(source)
                 project.components.append(component)
             product.projects.append(project)
         Session.add(product)
     Session.commit()
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:30,代碼來源:test_packages_architecture.py

示例3: setUp

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
 def setUp(self):
     Session.begin()
     queue = Queue('testqueue')
     queueoption1 = QueueOption('check', '+helloworld', 100)
     queue.allowed_options = "check, build-deb-package"
     queue.options.append(queueoption1)
     Session.add(queue)
     Session.commit()
     self.queue = queue
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:11,代碼來源:test_queue.py

示例4: setUpModule

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
def setUpModule():

    # add all the needed objects in DB
    Session.begin()
    product = Product("product1")
    project = Project("project1")
    component = Component("component1")
    project.components.append(component)
    product.projects.append(project)
    Session.add(product)
    Session.commit()
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:13,代碼來源:test_packages_project.py

示例5: submit_edit

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_edit(self, id):
        """Processes edited product
        """

        product = get_object_or_404(Product, id)
        Session.begin()
        product.name = self.form_result['name']
        msg = "Product <b>%s</b> has been updated" % product.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/product', id=id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:14,代碼來源:product.py

示例6: submit_add

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_add(self):
        """Processes new submitted product
        """
        
        Session.begin()
        product = Product(self.form_result['name'])
        Session.add(product)
        msg = "A new product <b>%s</b> has been added" % product.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/packages')
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:14,代碼來源:product.py

示例7: submit_edit

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_edit(self, id):
        """Processes edited source
        """

        source = get_object_or_404(Source, id)
        Session.begin()
        source.name = self.form_result["name"]
        msg = "Source package <b>%s</b> has been updated" % source.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller="packages/source", action="index", id=id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:14,代碼來源:source.py

示例8: submit_binary

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_binary(self, id):
        """Processes new submitted binary
        """

        source = get_object_or_404(Source, id)
        Session.begin()
        binary = Binary(self.form_result["name"])
        source.binaries.append(binary)
        msg = "A new binary <b>%s</b> has been added" % binary.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller="packages/source", action="index", id=id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:15,代碼來源:source.py

示例9: submit_edit

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_edit(self, id):
        """Processes edited binary
        """

        binary = get_object_or_404(Binary, id)
        Session.begin()
        binary.name = self.form_result['name']
        msg = "Binary package <b>%s</b> has been updated" % binary.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/binary',
                           action='index',
                           id=id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:16,代碼來源:binary.py

示例10: submit_source

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_source(self, id):
        """Processes new submitted source
        """

        component = get_object_or_404(Component, id)
        Session.begin()
        source = Source(self.form_result['name'])
        component.sources.append(source)
        msg = "A new source <b>%s</b> has been added" % source.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/component', 
                           action='index',
                           id=id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:17,代碼來源:component.py

示例11: setUpModule

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
def setUpModule():

    # add all the needed objects in DB
    Session.begin()
    product = Product("product1")
    project = Project("project1")
    component = Component("component1")
    source = Source("source1")
    binary = Binary("binary")
    source.binaries.append(binary)
    component.sources.append(source)
    project.components.append(component)
    product.projects.append(project)
    Session.add(product)
    Session.commit()
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:17,代碼來源:test_packages_binary.py

示例12: submit_edit

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_edit(self, id):
        """Processes edited component
        """

        component = get_object_or_404(Component, id)
        Session.begin()
        component.name = self.form_result['name']
        component.description = self.form_result['description']
        msg = "Component <b>%s</b> has been updated" % component.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/component',
                           action='index',
                           id=id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:17,代碼來源:component.py

示例13: submit_project

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_project(self, id):
        """Processes new submitted project
        """
        
        product = get_object_or_404(Product, id)
        Session.begin()
        project = Project(self.form_result['name'])
        product.projects.append(project)
        msg = "A new project <b>%s</b> has been added" % project.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/product', 
                           action='index',
                           id=id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:17,代碼來源:product.py

示例14: submit_component

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def submit_component(self, id):
        """Processes new submitted component
        """

        project = get_object_or_404(Project, id)
        Session.begin()
        component = Component(self.form_result['name'])
        component.description = self.form_result['description']
        project.components.append(component)
        msg = "A new component <b>%s</b> has been added" % component.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/project', 
                           action='index',
                           id=id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:18,代碼來源:project.py

示例15: delete

# 需要導入模塊: from pacemaker.model.meta import Session [as 別名]
# 或者: from pacemaker.model.meta.Session import commit [as 別名]
    def delete(self, id):
        """Deletes a selected binary.
        """
        #TODO: check permisssions

        binary = get_object_or_404(Binary, id)

        name = binary.name
        Session.begin()
        Session.delete(binary)
        Session.commit()
        h.flash("The binary package <b>%s</b> has been deleted successfully" % \
                name)

        return redirect_to(controller='packages/source',
                           action='index',
                           id=binary.source_id)
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:19,代碼來源:binary.py


注:本文中的pacemaker.model.meta.Session.commit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。