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


Python DBSession.delete方法代码示例

本文整理汇总了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'))
开发者ID:getpenelope,项目名称:por.dashboard,代码行数:17,代码来源:application.py

示例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)
开发者ID:getpenelope,项目名称:por.dashboard,代码行数:44,代码来源:favourites.py

示例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}
开发者ID:getpenelope,项目名称:por.dashboard,代码行数:23,代码来源:views.py


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