Ignore:
Timestamp:
26.11.2008 10:45:44 (3 years ago)
Author:
mike
Message:

zms forum uses captchas to verify human interaction

Location:
CMESS/forum/branches/captcha/cmess
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • CMESS/forum/branches/captcha/cmess/forum/c_handler_captcha.py

    r305 r315  
    1 from org.cmess.forum.c_captcha_basic import C_Captcha_Basic 
    2 from org.cmess.forum.c_captcha_basic import C_Captcha_Dot_Net 
     1from com.zms.captcha.c_captcha_basic import C_Captcha_Basic 
     2from com.zms.captcha.c_captcha_basic import C_Captcha_Dot_Net 
    33 
    44class C_Handler_Captcha: 
    5         def __init__(self, mode): 
    6                 self.captcha_mode = mode 
    7                 self.obj_dict = {} 
    8                  
    9                 temp_obj = C_Captcha_Dot_Net() 
    10                 self.RegisterCaptchaObj(temp_obj.GetID(), temp_obj) 
     5        def __init__(self, zms_context): 
     6                try: 
     7                        if (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'captcha.net'): 
     8                                self.captcha_obj = C_Captcha_Dot_Net(zms_context) 
     9                        else: 
     10                                self.captcha_obj = None 
     11                except: 
     12                        self.captcha_obj = None 
    1113                 
    1214        def GetCaptchaContent(self): 
    13                 if (self.obj_dict.has_key(self.captcha_mode)): 
    14                         temp_result = self.obj_dict[self.captcha_mode].GetContent() 
     15                if (self.captcha_obj is not None): 
     16                        temp_result = self.captcha_obj.GetContent() 
    1517                else: 
    1618                        temp_result = '' 
     
    1820                return temp_result 
    1921         
    20         def IsCodeValid(self, REQUEST): 
    21                 if (self.obj_dict.has_key(self.captcha_mode)): 
    22                         temp_result = self.obj_dict[self.captcha_mode].IsCodeValid(REQUEST) 
     22        def IsCodeValid(self): 
     23                if (self.captcha_obj is not None): 
     24                        temp_result = self.captcha_obj.IsCodeValid() 
    2325                else: 
    2426                        temp_result = False 
    2527                 
    2628                return temp_result 
    27          
    28         def RegisterCaptchaObj(self, id, obj): 
    29                 if (obj is not None and isinstance(obj, C_Captcha_Basic)): 
    30                         if (self.obj_dict.has_key(id)): 
    31                                 self.obj_dict.update({id : obj}) 
    32                         else: 
    33                                 self.obj_dict[id] = obj 
Note: See TracChangeset for help on using the changeset viewer.