本文整理匯總了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}