本文整理汇总了Python中fts3rest.lib.base.Session.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Session.delete方法的具体用法?Python Session.delete怎么用?Python Session.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fts3rest.lib.base.Session
的用法示例。
在下文中一共展示了Session.delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: popDelegation
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def popDelegation(self):
cred = self.getUserCredentials()
if cred and cred.delegation_id:
delegated = Session.query(Credential).get((cred.delegation_id, cred.user_dn))
if delegated:
Session.delete(delegated)
Session.commit()
示例2: update_app
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def update_app(self, client_id):
"""
Update an application
"""
user = pylons.request.environ['fts3.User.Credentials']
app = Session.query(OAuth2Application).get(client_id)
if not app:
raise HTTPNotFound('Application not found')
if app.owner != user.user_dn:
raise HTTPForbidden()
if pylons.request.headers['Content-Type'].startswith('application/json'):
fields = json.loads(pylons.request.body)
else:
fields = pylons.request.POST
try:
if 'delete' not in fields:
app.description = fields.get('description', '')
app.website = fields.get('website', '')
app.redirect_to = fields.get('redirect_to', '')
Session.merge(app)
Session.commit()
redirect(url_for(controller='oauth2', action='get_app'), code=HTTPSeeOther.code)
else:
Session.delete(app)
Session.query(OAuth2Token).filter(OAuth2Token.client_id == client_id).delete()
Session.query(OAuth2Code).filter(OAuth2Code.client_id == client_id).delete()
Session.commit()
redirect(url_for(controller='oauth2', action='get_my_apps'), code=HTTPSeeOther.code)
except:
Session.rollback()
raise
示例3: pop_delegation
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def pop_delegation(self):
"""
Remove the mock proxy from the database
"""
cred = self.get_user_credentials()
if cred and cred.delegation_id:
delegated = Session.query(Credential).get((cred.delegation_id, cred.user_dn))
if delegated:
Session.delete(delegated)
Session.commit()
示例4: is_access_requested
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def is_access_requested(self):
info = self._get_dropbox_user_info()
if info is None:
raise HTTPNotFound('No registered user for the service "%s" has been found' % self.service)
if info.is_registered():
res = self._get_content("/")
if res.startswith("401"):
try:
Session.delete(info)
Session.commit()
except:
Session.rollback()
raise
raise HTTPNotFound('No registered user for the service "%s" has been found' % self.service)
return info
示例5: test_put_cred_without_cache
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def test_put_cred_without_cache(self):
"""
This is a regression test. It tries to PUT directly
credentials without the previous negotiation, so there is no
CredentialCache in the database. This attempt must fail.
"""
self.setup_gridsite_environment()
creds = self.get_user_credentials()
request = self.app.get(url="/delegation/%s/request" % creds.delegation_id,
status=200)
proxy = self.get_x509_proxy(request.body)
Session.delete(Session.query(CredentialCache).get((creds.delegation_id, creds.user_dn)))
self.app.put(url="/delegation/%s/credential" % creds.delegation_id,
params=proxy,
status=400)
示例6: delete
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def delete(self, dlg_id, start_response):
"""
Delete the delegated credentials from the database
"""
user = request.environ['fts3.User.Credentials']
if dlg_id != user.delegation_id:
raise HTTPForbidden('The requested ID and the credentials ID do not match')
cred = Session.query(Credential).get((user.delegation_id, user.user_dn))
if not cred:
raise HTTPNotFound('Delegated credentials not found')
else:
try:
Session.delete(cred)
Session.commit()
except Exception:
Session.rollback()
raise
start_response('204 No Content', [])
return ['']
示例7: unban_se
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def unban_se(self, start_response):
"""
Unban a storage element
"""
storage = request.params.get('storage', None)
if not storage:
raise HTTPBadRequest('Missing storage parameter')
banned = Session.query(BannedSE).get(storage)
if banned:
try:
Session.delete(banned)
Session.commit()
except Exception:
Session.rollback()
log.warn("Storage %s unbanned" % storage)
else:
log.warn("Unban of storage %s without effect" % storage)
start_response('204 No Content', [])
return ['']
示例8: unban_dn
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def unban_dn(self, start_response):
"""
Unban a user
"""
dn = request.params.get('user_dn', None)
if not dn:
raise HTTPBadRequest('Missing user_dn parameter')
banned = Session.query(BannedDN).get(dn)
if banned:
try:
Session.delete(banned)
Session.commit()
except Exception:
Session.rollback()
log.warn("User %s unbanned" % dn)
else:
log.warn("Unban of user %s without effect" % dn)
start_response('204 No Content', [])
return ['']
示例9: delete_app
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import delete [as 别名]
def delete_app(self, client_id):
"""
Delete an application from the database
"""
user = pylons.request.environ['fts3.User.Credentials']
app = Session.query(OAuth2Application).get(client_id)
if app is None:
raise HTTPNotFound('Application not found')
if app.owner != user.user_dn:
raise HTTPForbidden()
try:
Session.delete(app)
Session.query(OAuth2Token).filter(OAuth2Token.client_id == client_id).delete()
Session.query(OAuth2Code).filter(OAuth2Code.client_id == client_id).delete()
Session.commit()
except:
Session.rollback()
raise
log.info("Application removed: %s" % client_id)
return None