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


Python CaptchaStore.create_pool方法代码示例

本文整理汇总了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')
开发者ID:RDXT,项目名称:django-simple-captcha,代码行数:9,代码来源:captcha_create_pool.py

示例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
开发者ID:RDXT,项目名称:django-simple-captcha,代码行数:21,代码来源:tests.py


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