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


Python DBSession.get方法代码示例

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


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

示例1: filter_stream

# 需要导入模块: from penelope.core.models import DBSession [as 别名]
# 或者: from penelope.core.models.DBSession import get [as 别名]
    def filter_stream(self, req, method, filename, stream, data):
        """Return a filtered Genshi event stream, or the original unfiltered
        stream if no match.

        `req` is the current request object, `method` is the Genshi render
        method (xml, xhtml or text), `filename` is the filename of the template
        to be rendered, `stream` is the event stream and `data` is the data for
        the current template.

        See the Genshi documentation for more information.
        """
        if filename == 'ticket.html':
            ticket = data['ticket']
            if ticket.exists:
                if req.perm.has_permission('SENSITIVE_VIEW'):
                    qry = DBSession().query(CustomerRequest)
                    if not qry.get(ticket.values.get('customerrequest')).active:
                        div = tag.div(
                            tag.div(
                                tag.strong(u'Heads up! '),
                                tag.span(u'This ticket is assigned to an inactive customer request.',),
                                class_="alert alert-info"),
                            id='inactive_cr_ticket')
                        return stream | Transformer("//div[@id='ticket']").before(div)
        return stream
开发者ID:getpenelope,项目名称:penelope.trac,代码行数:27,代码来源:plugins.py

示例2: TicketModule_grouped_changelog_entries

# 需要导入模块: from penelope.core.models import DBSession [as 别名]
# 或者: from penelope.core.models.DBSession import get [as 别名]
    def TicketModule_grouped_changelog_entries(self, ticket, db, when=None):
        ret = _grouped_changelog_entries(self, ticket, db, when)
        for item in ret:
            try:
                cr = item['fields']['customerrequest']
                qry = DBSession().query(CustomerRequest)
                old_cr = qry.get(cr['old'])
                new_cr = qry.get(cr['new'])
                cr['old'] = old_cr.name if old_cr else cr['old']
                cr['new'] = new_cr.name if new_cr else cr['new']
            except KeyError:
                pass

            yield item
开发者ID:getpenelope,项目名称:penelope.trac,代码行数:16,代码来源:monkey.py


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