本文整理汇总了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
示例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)
示例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