comparison bitsyauth/__init__.py @ 19:aac4a4ea70a7

whitespace
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 17 Nov 2011 11:06:40 -0800
parents 814ed3208afa
children 9f4369b769d0
comparison
equal deleted inserted replaced
18:814ed3208afa 19:aac4a4ea70a7
254 captcha = StringIO() 254 captcha = StringIO()
255 255
256 captcha_text = "Please type the word below so I know you're not a computer:" 256 captcha_text = "Please type the word below so I know you're not a computer:"
257 captcha_help = "(please %s if the page is unreadable)" % markup.link('/join?captcha=image', 'go here') 257 captcha_help = "(please %s if the page is unreadable)" % markup.link('/join?captcha=image', 'go here')
258 258
259 print >> captcha, markup.p('%s<br/> %s' % (captcha_text, 259 print >> captcha, markup.p('%s<br/> %s' % (captcha_text,
260 markup.i(captcha_help))) 260 markup.i(captcha_help)))
261 261
262 # determine type of CAPTCHA 262 # determine type of CAPTCHA
263 captchas = ' '.join(self.request.GET.getall('captcha')) 263 captchas = ' '.join(self.request.GET.getall('captcha'))
264 if not captchas: 264 if not captchas:
265 captchas = 'pre' 265 captchas = 'pre'
266 266
267 captcha_funcs=dict(pre=self.captcha_pre, 267 captcha_funcs=dict(pre=self.captcha_pre,
268 image=self.captcha_png,) 268 image=self.captcha_png,)
269 captchas = [ captcha_funcs[i](word, key) for i in captchas.split() 269 captchas = [ captcha_funcs[i](word, key) for i in captchas.split()
270 if i in captcha_funcs ] 270 if i in captcha_funcs ]
271 captchas = '\n'.join([markup.p(i) for i in captchas]) 271 captchas = '\n'.join([markup.p(i) for i in captchas])
272 print >> captcha, captchas 272 print >> captcha, captchas
273
274 print >> captcha, markup.p(markup.input(None, **dict(name='captcha', type='text'))) 273 print >> captcha, markup.p(markup.input(None, **dict(name='captcha', type='text')))
275 274
276 captcha = captcha.getvalue() 275 captcha = captcha.getvalue()
277 276
278 form = Form(action=self.urls['join'], submit='Join', post_html=captcha) 277 form = Form(action=self.urls['join'], submit='Join', post_html=captcha)
279 form.add_element('textfield', 'Name') 278 form.add_element('textfield', 'Name')
280 form.add_password_confirmation() 279 form.add_password_confirmation()
316 word = self.keys.pop(key, None) 315 word = self.keys.pop(key, None)
317 if not word: 316 if not word:
318 errors['CAPTCHA'] = 'Please type the funky looking word' 317 errors['CAPTCHA'] = 'Please type the funky looking word'
319 if word != self.request.POST.get('captcha','').lower(): 318 if word != self.request.POST.get('captcha','').lower():
320 errors['CAPTCHA'] = 'Sorry, you typed the wrong word' 319 errors['CAPTCHA'] = 'Sorry, you typed the wrong word'
321 320
322 name = self.request.POST.get('Name', '') 321 name = self.request.POST.get('Name', '')
323 if not name: 322 if not name:
324 if not errors.has_key('Name'): 323 if not errors.has_key('Name'):
325 errors['Name'] = [] 324 errors['Name'] = []
326 errors['Name'].append('Please enter a user name') 325 errors['Name'].append('Please enter a user name')