当前位置: 首页>>代码示例>>Python>>正文


Python Config.getboolean方法代码示例

本文整理汇总了Python中util.config.Config.getboolean方法的典型用法代码示例。如果您正苦于以下问题:Python Config.getboolean方法的具体用法?Python Config.getboolean怎么用?Python Config.getboolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util.config.Config的用法示例。


在下文中一共展示了Config.getboolean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import getboolean [as 别名]
	def get(self, user_id, page_id):

		ratelimit_key = self.ratelimit_key_template % self.request.remote_ip
		remote_ip_rate = Cache.incr(ratelimit_key)
		if remote_ip_rate is None:
			Cache.set(ratelimit_key, 1, time=60)
		elif remote_ip_rate > 60:
			self.set_status(503)
			self.set_header('Retry-After', '60')
			self.write('Rate limit exceeded. Please do not make more than 60 requests per minute.')

			# Don't log every single time we rate limit a host (that would get spammy fast),
			# but do log significant breakpoints on exactly how spammy a host is being.
			if remote_ip_rate in (61, 100, 1000, 10000):
				logging.info('Rate limited IP %s - %s requests/min' % (self.request.remote_ip, remote_ip_rate))

			return self.finish()

		self.gplus_user_id = user_id
		self.gplus_page_id = page_id

		if len(user_id) != 21:
			self.write("Google+ profile IDs are exactly 21 digits long. Please specify a proper profile ID.")
			return self.finish()

		if page_id and len(page_id) != 21:
			self.write("Google+ page IDs are exactly 21 digits long. Please specify a proper page ID.")

		self.cache_key = self.cache_key_template % user_id
		if page_id:
			self.cache_key += str(page_id)

		cached_result = Cache.get(self.cache_key)
		flush_requested = self.request.arguments.get('flush', [None])[0]
		if cached_result:
			if not Config.getboolean('cache', 'allow-flush') or not flush_requested:
				return self._respond(**cached_result)

		if page_id:
			OAuth2Handler.authed_fetch(user_id, self.json_url % (page_id, self.request.remote_ip), self._on_api_response)
		else:
			OAuth2Handler.authed_fetch(user_id, self.json_url % ('me', self.request.remote_ip), self._on_api_response)
开发者ID:astore,项目名称:pluss,代码行数:44,代码来源:atom.py

示例2: Cache

# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import getboolean [as 别名]
import hashlib
import json
import logging

from util.config import Config

if Config.getboolean('cache', 'memcache'):
	try:
		import memcache
		_hush_pyflakes = (memcache,)
		del _hush_pyflakes
	except ImportError:
		logging.error("Config file has memcache enabled, but couldn't import memcache! Not caching data.")
		memcache = None
else:
	memcache = None

class Cache(object):
	"""Wrapper around a singleton memcache client.

	Note: If the 'memcache' library is not available,
	this wrapper will do nothing - call() will transparently
	always call the provided function, and everything else
	will simply return None.
	"""

	client = memcache and memcache.Client([Config.get('cache', 'memcache-uri')], debug=0)

	@classmethod
	def call(cls, func, *args, **kwargs):
		if not cls.client:
开发者ID:astore,项目名称:pluss,代码行数:33,代码来源:cache.py


注:本文中的util.config.Config.getboolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。