source: CMESS/captcha/trunk/com/zms/captcha/c_handler_captcha.py @ 362

Revision 362, 1.2 KB checked in by mike, 3 years ago (diff)
  • added ReCaptcha?-service
  • added PILCaptcha-service
Line 
1from com.zms.captcha.c_captcha_basic import C_Captcha_Basic
2from com.zms.captcha.c_captcha_basic import C_Captcha_Dot_Net
3from com.zms.captcha.c_captcha_basic import C_PIL_Captcha
4from com.zms.captcha.c_captcha_basic import C_ReCaptcha
5
6class C_Handler_Captcha:
7        def __init__(self, zms_context):
8                try:
9                        if (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'captchas.net'):
10                                self.captcha_obj = C_Captcha_Dot_Net(zms_context)
11                        elif (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'PILCaptcha'):
12                                self.captcha_obj = C_PIL_Captcha(zms_context)
13                        elif (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'reCaptcha'):
14                                self.captcha_obj = C_ReCaptcha(zms_context)
15                        else:
16                                self.captcha_obj = None
17                except:
18                        self.captcha_obj = None
19               
20        def GetCaptchaContent(self):
21                if (self.captcha_obj is not None):
22                        temp_result = self.captcha_obj.GetContent()
23                else:
24                        temp_result = ''
25               
26                return temp_result
27       
28        def IsCodeValid(self):
29                if (self.captcha_obj is not None):
30                        temp_result = self.captcha_obj.IsCodeValid()
31                else:
32                        temp_result = (True, '')
33               
34                return temp_result
Note: See TracBrowser for help on using the repository browser.