本文整理汇总了Python中fts3rest.lib.base.Session.add方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add方法的具体用法?Python Session.add怎么用?Python Session.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fts3rest.lib.base.Session
的用法示例。
在下文中一共展示了Session.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_access_granted
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import add [as 别名]
def get_access_granted(self):
dropbox_user_info = self._get_dropbox_user_info()
if not dropbox_user_info:
raise HTTPBadRequest('No registered user for the service "%s" has been found' % self.service)
dropbox_info = self._get_dropbox_info()
if not dropbox_info:
raise HTTPNotFound('Dropbox info not found in the databse')
access_tokens = self._make_call(
dropboxApiEndpoint + "/1/oauth/access_token",
'OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="' +
dropbox_info.app_key + '", oauth_token="' + dropbox_user_info.request_token +
'", oauth_signature="' + dropbox_info.app_secret + '&' + dropbox_user_info.request_token_secret + '"',
None
)
# It returns: oauth_token=<access-token>&oauth_token_secret=<access-token-secret>&uid=<user-id>
access_tokens = access_tokens.split('&')
dropbox_user_info.access_token = access_tokens[1].split('=')[1]
dropbox_user_info.access_token_secret = access_tokens[0].split('=')[1]
try:
Session.add(dropbox_user_info)
Session.commit()
except:
Session.rollback()
raise
return access_tokens
示例2: get_access_requested
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import add [as 别名]
def get_access_requested(self):
dropbox_info = self._get_dropbox_info()
request_tokens = self._make_call(
dropboxApiEndpoint + "/1/oauth/request_token",
'OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT",'
'oauth_consumer_key="' + dropbox_info.app_key + '", oauth_signature="' + dropbox_info.app_secret + '&"',
None
)
# It returns: oauth_token_secret=b9q1n5il4lcc&oauth_token=mh7an9dkrg59
tokens = request_tokens.split('&')
newuser = CloudStorageUser(
user_dn=self.user_dn,
cloudStorage_name=dropbox_info.cloudStorage_name,
request_token=tokens[1].split('=')[1],
request_token_secret=tokens[0].split('=')[1]
)
try:
Session.add(newuser)
Session.commit()
except:
Session.rollback()
raise
return request_tokens
示例3: request
# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import add [as 别名]
def request(self, id, start_response):
user = request.environ['fts3.User.Credentials']
credentialCache = Session.query(CredentialCache).get((id, user.user_dn))
if credentialCache is None:
(proxyRequest, proxyKey) = generateProxyRequest(user.dn)
credentialCache = CredentialCache(dlg_id = user.delegation_id,
dn = user.user_dn,
cert_request = proxyRequest.as_pem(),
priv_key = proxyKey.as_pem(cipher = None),
voms_attrs = ' '.join(user.voms_cred))
Session.add(credentialCache)
Session.commit()
start_response('200 OK', [('X-Delegation-ID', credentialCache.dlg_id)])
return credentialCache.cert_request