Changeset 665

Show
Ignore:
Timestamp:
11/28/06 10:41:28
Author:
crchemist
Message:

Modified captchas tool installation to be compatible with Plone-2.0.5

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneCaptchas/trunk/CaptchaTool.py

    r664 r665  
    33from AccessControl import ClassSecurityInfo 
    44 
    5 def constructCaptchaTool(self, id, title='', timeout_mins=20, 
    6                          addNotification=None, delNotification=None, 
    7                          limit=0, period_secs=20, 
    8                          REQUEST=None): 
    9     ob = CaptchaTool(id, title, timeout_mins, 
    10                      addNotification, delNotification, 
    11                      limit=limit, period_secs=period_secs) 
    12     self._setObject(id, ob) 
    13     if REQUEST is not None: 
    14         return self.manage_main(self, REQUEST, update_menu=1) 
    15  
    165class CaptchaTool(TransientObjectContainer): 
    176    """portal_captcha tool class 
    187    """ 
     8    meta_type = 'CaptchaTool' 
    199    security = ClassSecurityInfo() 
    2010    security.declarePublic('addExpiredKey') 
     11 
     12    def __init__(self, id='portal_captchas', title='', timeout_mins=60, addNotification=None, 
     13                 delNotification=None, limit=0, period_secs=60): 
     14        TransientObjectContainer.__init__(self, id, title, timeout_mins, addNotification, 
     15                                          delNotification, limit, period_secs) 
     16 
    2117    def addExpiredKey(self, key): 
    2218        self.new(key) 
  • qPloneCaptchas/trunk/Extensions/Install.py

    r664 r665  
    11from Products.qPloneCaptchas.config import * 
    2 from Products.qPloneCaptchas.CaptchaTool import constructCaptchaTool 
    32from Products.CMFCore.utils import getToolByName 
    43from StringIO import StringIO 
     
    1514    portal = getToolByName(self, 'portal_url').getPortalObject() 
    1615    # add captchas_tool 
    17     if not hasattr(portal, TOOL_ID): 
    18         constructCaptchaTool(portal, id=TOOL_ID, timeout_mins=60) 
     16    install_tool(self, out) 
    1917 
    2018    safeEditProperty(self, 'captcha_key', generateKey(8)) 
     
    10199    for i in range(length): key += str(randint(0, 9)) 
    102100    return key 
     101 
     102def install_tool(self, out): 
     103    if not hasattr(self, 'portal_captchas'): 
     104        addTool = self.manage_addProduct['qPloneCaptchas'].manage_addTool 
     105        addTool('CaptchaTool') 
  • qPloneCaptchas/trunk/__init__.py

    r664 r665  
    1111tools = (CaptchaTool.CaptchaTool, ) 
    1212def initialize(context): 
    13     context.registerClass(CaptchaTool.CaptchaTool, 
    14                           constructors=(CaptchaTool.constructCaptchaTool,)) 
    15  
    16     ToolInit("CaptchaTool", 
     13    ToolInit(meta_type="CaptchaTool", 
    1714             tools=tools, 
     15             product_name=config.PRODUCT_NAME, 
    1816             icon=config.TOOL_ICON,).initialize(context)