本文整理汇总了Python中captcha.models.CaptchaStore.create_pool方法的典型用法代码示例。如果您正苦于以下问题:Python CaptchaStore.create_pool方法的具体用法?Python CaptchaStore.create_pool怎么用?Python CaptchaStore.create_pool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类captcha.models.CaptchaStore
的用法示例。
在下文中一共展示了CaptchaStore.create_pool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from captcha.models import CaptchaStore [as 别名]
# 或者: from captcha.models.CaptchaStore import create_pool [as 别名]
def handle(self, **options):
verbose = int(options.get('verbosity'))
count = options.get('pool_size')
CaptchaStore.create_pool(count)
verbose and self.stdout.write('Created %d new captchas\n' % count)
options.get('cleanup_expired') and CaptchaStore.remove_expired()
options.get('cleanup_expired') and verbose and self.stdout.write('Expired captchas cleaned up\n')
示例2: test_get_from_pool
# 需要导入模块: from captcha.models import CaptchaStore [as 别名]
# 或者: from captcha.models.CaptchaStore import create_pool [as 别名]
def test_get_from_pool(self):
__current_test_get_from_pool_setting = settings.CAPTCHA_GET_FROM_POOL
__current_test_get_from_pool_timeout_setting = settings.CAPTCHA_GET_FROM_POOL_TIMEOUT
__current_test_timeout_setting = settings.CAPTCHA_TIMEOUT
settings.CAPTCHA_GET_FROM_POOL = True
settings.CAPTCHA_GET_FROM_POOL_TIMEOUT = 5
settings.CAPTCHA_TIMEOUT = 90
CaptchaStore.objects.all().delete() # Delete objects created during SetUp
POOL_SIZE = 10
CaptchaStore.create_pool(count=POOL_SIZE)
self.assertEqual(CaptchaStore.objects.count(), POOL_SIZE)
pool = CaptchaStore.objects.values_list('hashkey', flat=True)
random_pick = CaptchaStore.pick()
self.assertIn(random_pick, pool)
# pick() should not create any extra captcha
self.assertEqual(CaptchaStore.objects.count(), POOL_SIZE)
settings.CAPTCHA_GET_FROM_POOL = __current_test_get_from_pool_setting
settings.CAPTCHA_GET_FROM_POOL_TIMEOUT = __current_test_get_from_pool_timeout_setting
settings.CAPTCHA_TIMEOUT = __current_test_timeout_setting