本文整理汇总了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
示例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