comparison captchamiddleware/middleware.py @ 1:478d13061336

include a text input
author k0s <k0scist@gmail.com>
date Sat, 06 Feb 2010 19:00:32 -0500
parents 21ec6325ae0e
children c861518b2a44
comparison
equal deleted inserted replaced
0:21ec6325ae0e 1:478d13061336
62 62
63 for element in tree.findall(".//form[@method='post']"): 63 for element in tree.findall(".//form[@method='post']"):
64 key = random.Random().randint(0, len(self.words)) 64 key = random.Random().randint(0, len(self.words))
65 word = self.words[key] 65 word = self.words[key]
66 captcha = skimpyAPI.Pre(word).data() 66 captcha = skimpyAPI.Pre(word).data()
67 string = '<div class="captcha">%s<input type="hidden" value="%s"/></div>' % (captcha, key) 67 string = '<div class="captcha">%s<input type="hidden" value="%s"/><input type="text" name="captcha"/></div>' % (captcha, key)
68 addition = etree.fromstring(string) 68 addition = etree.fromstring(string)
69 insertion_point = element.find('.' + self.path) 69 insertion_point = element.find('.' + self.path)
70 insertion_point.addprevious(addition) 70 insertion_point.addprevious(addition)
71 71
72 return tree 72 return tree