本文整理汇总了Python中gsocial.log.Log.info方法的典型用法代码示例。如果您正苦于以下问题:Python Log.info方法的具体用法?Python Log.info怎么用?Python Log.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gsocial.log.Log
的用法示例。
在下文中一共展示了Log.info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_warn
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import info [as 别名]
def test_warn(self):
"""
関数が問題なく通るかのみ確認
"""
msg = 'Simplejson Error4.'
obj = 'hoge'
Log.info(msg, obj)
示例2: set_cache
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import info [as 别名]
def set_cache(cls, cache_key, cache_value, timeout=None):
"""
キャッシュにセットする
アプリ側のsettingsのtimeoutがあれば使う
なければgsocialのsettingのtimeoutを使う
"""
if timeout == None:
# ここは普通のif文に変更した方がよいかも
try:
timeout = settings.GSOCIAL_CACHE_TIMEOUT
except AttributeError:
Log.info('GSOCIAL_CACHE_TIMEOUT isn\'t in settings.', timeout)
timeout = DEFALT_CACHE_TIMEOUT
Log.debug('Check timeout.', timeout)
cache.set(cache_key, cache_value, timeout)
示例3: _verify_sign_header
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import info [as 别名]
def _verify_sign_header(request):
"""
OAuth checking of header
output
authorization ok :None
else: raise
ヘッダーのOAUTH認証
output
認証ok: None
それ以外: raise
"""
Log.debug("[Method] _verify_sign_header")
request.opensocial_container = containerdata
#下記つかってないのでコメントアウト
#header_params = {}
#oauth_signature = request.REQUEST.get("oauth_signature", None)
auth_string = request.META.get('HTTP_AUTHORIZATION',"")
auth_string = auth_string.replace('OAuth ',"")
Log.debug('HTTP_AUTHORIZATION', auth_string)
params = {}
remote_hash = False
for param in auth_string.split(','):
Log.debug('param', param)
(key, value) = param.strip().split('=', 1)
value = value.strip('"').encode('utf-8')
if key == 'oauth_signature':
remote_hash = base64.decodestring(urllib.unquote(value))
elif key and key != 'OAuth realm' and key != 'realm':
params[key] = value
Log.debug('params', params)
if not remote_hash:
raise
oauth_token_secret = params.get('oauth_token_secret', '')
# Some container only need query parameter to create base_string
# while some need postdata as well,so you create both hash pattern.
# As one of them matches,checking will be passed.
# コンテナによって、base_stringを作成するのにクエリパラメータのみを使うもの、
# postdataも含めるものがあるので、両方のパターンのハッシュを作り
# どちらかがマッチすれば認証OKとする。
encoding = request.encoding
if not encoding:
encoding = 'utf-8'
for key, value in request.GET.items():
if key and key != 'oauth_signature':
params[key] = value.encode(encoding)
Log.debug('params', params)
# local_hash1 = local_hash2 = u''
#create hash by only using query parameter.
# クエリパラメータのみを使ってハッシュを作成
local_hash1 = create_hmac_hash(request, params, oauth_token_secret)
# create hash with using parameter contain POSTDATA
# POSTDATAも含めたパラメータを使ってハッシュを作成
post_param = generate_post_hash(request, encoding)
params.update(post_param)
local_hash2 = create_hmac_hash(request, params, oauth_token_secret)
host = request.get_host()
host = host.split(',')[0]
base_url = request.is_secure() and 'https://' or 'http://' + host + request.path
Log.info('base_url', base_url)
for k, v in params.iteritems():
if isinstance(v, basestring):
Log.info('Check k and v.decode(encoding) of params.iteritems()', [k, v.decode(encoding)])
else:
Log.info('Check k and v of params.iteritems()', [k, v])
Log.info('raw', request.raw_post_data)
Log.info('remote_hash', binascii.b2a_base64(remote_hash)[:-1])
Log.info('local_hash1', binascii.b2a_base64(local_hash1)[:-1])
Log.info('local_hash2', binascii.b2a_base64(local_hash2)[:-1])
Log.info('local_hash1 == remote_hash ?', (local_hash1 == remote_hash))
Log.info('local_hash2 == remote_hash ?', (local_hash2 == remote_hash))
if local_hash1 != remote_hash and local_hash2 != remote_hash:
raise
opensocial_owner_id = request.REQUEST.get('opensocial_owner_id', None)
if opensocial_owner_id is not None:
request.opensocial_userid = str(opensocial_owner_id)
request.opensocial_viewer_id = str(opensocial_owner_id)
return None