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


Python DBSession.delete方法代码示例

本文整理汇总了Python中tap.models.DBSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.delete方法的具体用法?Python DBSession.delete怎么用?Python DBSession.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tap.models.DBSession的用法示例。


在下文中一共展示了DBSession.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: permission_save

# 需要导入模块: from tap.models import DBSession [as 别名]
# 或者: from tap.models.DBSession import delete [as 别名]
 def permission_save(self):
     result = dict(success=0, message="")
     with transaction.manager:
         user_id = self.request.params['user_id']
         permissions = self.request.params['permissions']
         db_list = DBSession.query(TapUserPermission).filter_by(
             user_id=user_id)
         for permission in db_list:
             DBSession.delete(permission)
         # permissionid-view:1,add:0,delete,0,edit,0;
         for section in permissions.split(';'):
             permission_id, permission_str = section.split('-')
             permission = DBSession.query(TapPermission).get(permission_id)
             if not permission:
                 result["message"] = "不存在的Permission Id: %s" \
                                     % permission_id
                 return result
             upermission = TapUserPermission(user_id=user_id,
                                             permission_id=permission_id)
             DBSession.add(upermission)
             for detail in permission_str.split(','):
                 print detail
                 permission_type, value = detail.split(':')
                 value = int(value)
                 if permission_type == 'view':
                     upermission.a_view = value
                 elif permission_type == 'add':
                     upermission.a_add = value
                 elif permission_type == 'delete':
                     upermission.a_delete = value
                 elif permission_type == 'edit':
                     upermission.a_edit = value
     result['success'] = 1
     return result
开发者ID:vincentwyshan,项目名称:tap,代码行数:36,代码来源:actions.py

示例2: client_paradelete

# 需要导入模块: from tap.models import DBSession [as 别名]
# 或者: from tap.models.DBSession import delete [as 别名]
    def client_paradelete(self):
        result = dict(success=0, message="")
        request = self.request
        para_id = request.params.get('id')
        try:

            with transaction.manager:
                para_id = int(para_id)
                para = DBSession.query(TapApiClientCustomPara).get(para_id)
                DBSession.delete(para)
                result["success"] = 1
        except BaseException, e:
            result["message"] = str(e)
开发者ID:vincentwyshan,项目名称:tap,代码行数:15,代码来源:actions.py

示例3: validate

# 需要导入模块: from tap.models import DBSession [as 别名]
# 或者: from tap.models.DBSession import delete [as 别名]
def validate(captcha_id, code):
    with transaction.manager:
        captcha = DBSession.query(CaptchaCode).get(captcha_id)
        if not captcha:
            return False
        # 大约有 1% 的概率,执行清除一天前的旧数据任务
        if random.random() < 0.01:
            today = datetime.date.today()
            today = datetime.datetime(today.year, today.month, today.day)
            DBSession.query(CaptchaCode).filter(
                CaptchaCode.created<today).delete()

        result = captcha.code.lower() == code.lower()
        DBSession.delete(captcha)
        return result
开发者ID:vincentwyshan,项目名称:tap,代码行数:17,代码来源:tcaptcha.py


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