本文整理汇总了Python中models.DBSession.merge方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.merge方法的具体用法?Python DBSession.merge怎么用?Python DBSession.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.DBSession
的用法示例。
在下文中一共展示了DBSession.merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import merge [as 别名]
def put(self):
uid = self.request.matchdict['uid']
server = DBSession.query(Server).filter_by(uid=uid).one()
data = self.request.json
with transaction.manager:
for k,v in data.items():
setattr(server, k, v)
DBSession.merge(server)
return {
'uid': server.uid,
'address': server.address,
'port': server.port,
'useSSL': server.useSSL
}
示例2: generic_edit_view
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import merge [as 别名]
def generic_edit_view(request, form, record=None, redirect='../'):
'''a generic edit view, it must receive a request and a form.
if record is None, will edit the request.context variable.
default value for undefined is ../'''
record = record or request.context
if request.POST:
form_items = request.POST.items()
try:
appstruct = form.validate(form_items)
except deform.ValidationFailure, e:
return {'form' : e.render(),
'requirements' : form.get_widget_resources()}
record = merge_appstruct(record, appstruct)
DBSession.merge(record)
return HTTPFound(location=redirect)