本文整理汇总了Python中por.models.DBSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.delete方法的具体用法?Python DBSession.delete怎么用?Python DBSession.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类por.models.DBSession
的用法示例。
在下文中一共展示了DBSession.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: security_save
# 需要导入模块: from por.models import DBSession [as 别名]
# 或者: from por.models.DBSession import delete [as 别名]
def security_save(self):
context = self.context.get_instance()
for acl in context.acl:
DBSession.delete(acl)
for checkbox_name in self.request.POST:
role_id, permission_name = checkbox_name.split('.')
acl = ApplicationACL(application_id=context.id,
role_id=role_id,
permission_name=permission_name)
DBSession.add(acl)
request = self.request
return HTTPFound(location=request.fa_url(request.model_name, request.model_id, 'security'))
示例2: save_query
# 需要导入模块: from por.models import DBSession [as 别名]
# 或者: from por.models.DBSession import delete [as 别名]
def save_query(context, request):
current_uid = request.authenticated_user.id
query_meta = cgi.parse_qs(request.POST['query_meta'])
if not 'query_name' in query_meta:
return Response(u"Please specify a query name.", status=409)
query_name = query_meta['query_name'][0]
taken = DBSession.query(SavedQuery).filter(SavedQuery.author_id==current_uid).filter(SavedQuery.query_name==query_name).count()
submit_type = request.POST['submit_type']
if submit_type == 'submit_edit':
if taken:
return Response(u"Name already in use: '%s'." % query_name, status=409)
sq_id = query_meta['sq_id'][0]
qry = DBSession.query(SavedQuery)
qry = qry.filter(SavedQuery.author_id==current_uid)
qry = qry.filter(SavedQuery.id==sq_id)
sq = qry.one()
sq.query_name = query_name
return Response(u"The query has been renamed as '%s'." % query_name)
elif submit_type == 'submit_delete':
sq_id = query_meta['sq_id'][0]
qry = DBSession.query(SavedQuery)
qry = qry.filter(SavedQuery.author_id==current_uid)
qry = qry.filter(SavedQuery.id==sq_id)
sq = qry.one()
DBSession.delete(sq)
return Response(u"The saved query has been deleted.")
elif submit_type == 'submit_add':
if taken:
return Response(u"Name already in use: '%s'." % query_name, status=409)
# add
sq = SavedQuery(query_name=query_name,
report_name=query_meta['report_name'][0],
query_string=request.POST['query_string'],
author_id = current_uid)
DBSession.add(sq)
return Response(u"The query has been saved as '%s'." % query_name)
示例3: change_password
# 需要导入模块: from por.models import DBSession [as 别名]
# 或者: from por.models.DBSession import delete [as 别名]
def change_password(request):
session = DBSession()
token = request.params.get('token')
ptoken = session.query(PasswordResetToken).filter_by(token=token).first()
password = request.params.get('password')
repeat = request.params.get('password_repeat')
if not ptoken:
request.add_message(_(u'Token doesn\'t exist.'), type='danger')
elif password != repeat:
request.add_message(_(u'Passwords missmatch.'), type='danger')
elif not password or not repeat:
request.add_message(_(u'Missing password.'), type='danger')
elif len(password)<6:
request.add_message(_(u'Password too short. It needs to be at least 6 characters long.'), type='danger')
else:
ptoken.user.set_password(password)
session.delete(ptoken)
request.add_message(_(u'Password changed.'), type='success')
return HTTPFound(location='/login_form')
return {'request': request, 'token': token}