def __attach_token(self, url_str): user = settings.Params['auth']['user'] token_id = settings.Params['auth']['token'] md5_token, timestamp = api_token.get_token(user, token_id) url_arg_str = "user=%s×tamp=%s&token=%s" % (user, timestamp, md5_token) if "?" in url_str: #already has arg new_url = url_str + "&" + url_arg_str else: new_url = url_str + "?" + url_arg_str return new_url
def __attach_token(self,url_str): '''generate md5 by token_id and username,and attach it on the url request''' user = settings.Params['auth']['user'] token_id = settings.Params['auth']['token'] md5_token,timestamp = api_token.get_token(user,token_id) url_arg_str = "user=%s×tamp=%s&token=%s" %(user,timestamp,md5_token) if "?" in url_str:#already has arg new_url = url_str + "&" + url_arg_str else: new_url = url_str + "?" + url_arg_str return new_url