|
Last change
on this file was
1,
checked in by myroslav, 20 years ago
|
|
Building directory structure
|
-
Property svn:eol-style set to
native
|
|
File size:
825 bytes
|
| Line | |
|---|
| 1 | ## Script (Python) "getCaptchaImage" |
|---|
| 2 | ##bind container=container |
|---|
| 3 | ##bind context=context |
|---|
| 4 | ##bind namespace= |
|---|
| 5 | ##bind script=script |
|---|
| 6 | ##bind subpath=traverse_subpath |
|---|
| 7 | ##parameters= |
|---|
| 8 | ##title= |
|---|
| 9 | from Products.qPloneCaptchas.utils import gen_captcha, decrypt, \ |
|---|
| 10 | getWord, parseKey |
|---|
| 11 | from Products.qPloneCaptchas.config import havePIL |
|---|
| 12 | hk = context.REQUEST.traverse_subpath[0] |
|---|
| 13 | dk = decrypt(context.captcha_key, hk) |
|---|
| 14 | key = parseKey(dk)['key'] |
|---|
| 15 | |
|---|
| 16 | if havePIL: |
|---|
| 17 | im = gen_captcha(getWord(int(key)), 27) |
|---|
| 18 | context.REQUEST.RESPONSE.setHeader('Content-Type', 'image/jpeg') |
|---|
| 19 | context.REQUEST.RESPONSE.setHeader('Content-Length', im['size']) |
|---|
| 20 | context.REQUEST.RESPONSE.setHeader('Accept-Ranges', 'bytes') |
|---|
| 21 | return im['src'] |
|---|
| 22 | else: |
|---|
| 23 | img = getattr(context, '%s.jpg' % key) |
|---|
| 24 | return img.index_html(context.REQUEST, context.REQUEST.RESPONSE) |
|---|
Note: See
TracBrowser
for help on using the repository browser.