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


Python meta.Session類代碼示例

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


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

示例1: create_request

    def create_request(self, options):
        """This is a factory of Request objects.
        
        Creates a Request object with given options plus queue specific
        options. Should the options conflict the factory resolves
        the conflicts in the way that queue's options have precedence
        over given request options.

        options: list of tuple (name, value)
        """

        # Check if given options are allowed for this Queue object.
        allowed = self.get_allowed_options()
        LOG.debug("Allowed options: %s" % allowed)
        not_allowed = []
        for option, _ in options:
            if option not in allowed:
                not_allowed.append(option)
        if not_allowed:
            raise QueueError("Given request options are not allowed "
                             "for this Queue: %s" % ", ".join(not_allowed))

        # TODO: create effective options as intersection between
        #       'options' and self.options
        user_options = [(100, name, value) for name, value in options]
        request_options = [(o.priority, o.name, o.value) for o in self.options]
        request_options.extend(user_options)
        request_options.sort()
        request_options = tuple((o[1], o[2]) for o in request_options)

        request = Request(request_options)
        self.requests.append(request)
        Session.flush()
        return request
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:34,代碼來源:__init__.py

示例2: index

    def index(self, id):
        """Shows overview for product
        """

        log.debug("ProductController.index action invoked")
        product = get_object_or_404(Product, id)
        c.product_id = product.id
        c.product_name = product.name

        stmt = Session.query(Component.project_id, 
                             func.count('*').label('comp_count')).\
                group_by(Component.project_id).subquery()

        c.projects = []
        # SELECT project.*,comp_count FROM project LEFT JOIN (subquery)...
        for project, count in Session.query(Project, stmt.c.comp_count).\
                       outerjoin((stmt, Project.id==stmt.c.project_id)).\
                       filter(Project.product_id == product.id).\
                       order_by(Project.name):
            if not count:
                count = 0
            c.projects.append({'name': project.name,
                               'id': project.id,
                               'comp_count': count})

        return render('/packages/product_overview.mako')
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:26,代碼來源:product.py

示例3: index

    def index(self, id):

        component = get_object_or_404(Component, id)
        c.product_name = component.project.product.name
        c.project_id = component.project_id
        c.project_name = component.project.name
        c.product_id = component.project.product_id
        c.component_name = component.name
        c.component_id = id

        stmt = Session.query(Binary.source_id, 
                             func.count('*').label('bin_count')).\
                group_by(Binary.source_id).subquery()

        c.sources = []
        # SELECT source.*,bin_count FROM source LEFT JOIN (subquery)...
        for source, count in Session.query(Source, stmt.c.bin_count).\
                       outerjoin((stmt, Source.id==stmt.c.source_id)).\
                       filter(Source.component_id == component.id).\
                       order_by(Source.name):
            if not count:
                count = 0
            c.sources.append({'name': source.name,
                              'id': source.id,
                              'bin_count': count})

        return render('/packages/component_overview.mako')
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:27,代碼來源:component.py

示例4: index

    def index(self, id):

        project = get_object_or_404(Project, id)
        c.product_name = project.product.name
        c.project_id = id
        c.project_name = project.name
        c.product_id = project.product_id

        stmt = Session.query(Source.component_id, 
                             func.count('*').label('src_count')).\
                group_by(Source.component_id).subquery()

        c.components = []
        # SELECT component.*,src_count FROM component LEFT JOIN (subquery)...
        for component, count in Session.query(Component, stmt.c.src_count).\
                       outerjoin((stmt, Component.id==stmt.c.component_id)).\
                       filter(Component.project_id == project.id).\
                       order_by(Component.name):
            if not count:
                count = 0
            c.components.append({'name': component.name,
                                 'id': component.id,
                                 'src_count': count})

        return render('/packages/project_overview.mako')
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:25,代碼來源:project.py

示例5: __call__

 def __call__(self, environ, start_response):
     """Invoke the Controller"""
     # WSGIController.__call__ dispatches to the Controller method
     # the request is routed to. This routing information is
     # available in environ['pylons.routes_dict']
     try:
         return WSGIController.__call__(self, environ, start_response)
     finally:
         Session.remove()
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:9,代碼來源:base.py

示例6: submit_edit

    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,代碼行數:12,代碼來源:source.py

示例7: submit_edit

    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,代碼行數:12,代碼來源:product.py

示例8: submit_binary

    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,代碼行數:13,代碼來源:source.py

示例9: submit_edit

    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,代碼行數:14,代碼來源:binary.py

示例10: submit_edit

    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,代碼行數:15,代碼來源:component.py

示例11: submit_source

    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,代碼行數:15,代碼來源:component.py

示例12: submit_project

    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,代碼行數:15,代碼來源:product.py

示例13: test_index

    def test_index(self):

        # look up for object ID
        component = Session.query(Component).first()
        response = self.app.get(url(controller='packages/component',
                                        action='index',
                                        id=component.id))
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:7,代碼來源:test_packages_component.py

示例14: walktree

    def walktree(self, depth = 0, root = 'source'):
        """Recursion function to walk over the acrhitectural tree"""

        # our hierachy
        chain = ('product', 'project', 'component', 'source', 'binary')
        # plural forms
        chains = ('products', 'projects', 'components', 'sources', 'binaries', 
                  'stop')
        # agregation hierachy
        chainclass = (Product, Project, Component, Source, Binary)
        response = self.app.get(url(controller = 'packages/architecture',
                                        action = 'get_architecture_nodes'),
                                params = {'root': root})
        nodes = simplejson.loads(response.body)
        assert len(nodes) == 3, "AJAX returned wrong number of nodes"
        for node in nodes:
            assert node['classes'] == chain[depth] + 'item', \
                    "Wrong class of item"
            itemtype, id = node['id'].split('_')
            assert itemtype == chain[depth], \
                    "Wrong type of item"
            db_node = Session.query(chainclass[depth]).filter_by(id = id).one()
            if chains[depth + 1] != 'stop':
                subnodes = getattr(db_node, chains[depth + 1])
                if len(subnodes) > 0:
                    assert node['hasChildren'], "Wring hasChildren attribute"
                    self.walktree(depth + 1, node['id'])
                else:
                     assert not node['hasChildren'], \
                             "Wring hasChildren attribute"
            else:
                assert not node['hasChildren'], \
                        "Leaf node must not have children"
開發者ID:rojkov,項目名稱:pacemaker,代碼行數:33,代碼來源:test_packages_architecture.py

示例15: submit_component

    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,代碼行數:16,代碼來源:project.py


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