Changeset 7287 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 6 Dec 2011, 16:07:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/captcha.py
r7284 r7287 24 24 import urllib2 25 25 from zope import schema 26 from zope.component import getUtilitiesFor 26 from zope.component import getUtilitiesFor, getUtility, queryUtility 27 27 from zope.interface import Interface 28 28 from zope.publisher.interfaces.http import IHTTPRequest … … 96 96 """A chooser that collects available captchas. 97 97 """ 98 def getAvailCaptchas( self):98 def getAvailCaptchas(): 99 99 """Return a dict of available captchas with registered names as keys. 100 100 """ 101 101 102 def getCaptcha( self):102 def getCaptcha(): 103 103 """Get captcha chosen for a certain site or default. 104 104 """ 105 105 106 def getConfigData( self,captcha):106 def getConfigData(captcha): 107 107 """Get a dict of config data for a certain captcha. 108 108 """ 109 109 110 def setConfigData( self,captcha, key, value):110 def setConfigData(captcha, key, value): 111 111 """Set a certain configuration key for a certain captcha. 112 112 """ … … 130 130 """ 131 131 result = getUtilitiesFor(ICaptcha) 132 return dict([ x for xin result133 if x!= u''])132 return dict([(name,inst) for name,inst in result 133 if name != u'']) 134 134 135 135 def getCaptcha(self): 136 """Get captcha chosen to be used. 137 138 Sites can activate a specific captcha by setting 139 ``site['configuration']['captcha']``. The value should be a 140 string under which the specific captcha is registered. 141 142 If this value cannot be found (or is not set at all) or we are 143 not 'in a site', the default captcha is returned. 144 """ 136 145 site = grok.getSite() 137 146 name = '' 138 147 if site is None: 139 # return the default captcha, registered without name140 148 return getUtility(ICaptcha) 141 149 name = site.get('configuration', None).get('captcha', u'') 142 return getUtility(ICaptcha, name=name) 150 return queryUtility(ICaptcha, name=name, 151 default=getUtility(ICaptcha)) 143 152 144 153 #
Note: See TracChangeset for help on using the changeset viewer.