""" Plugin to test the nospam.py plugin. To install: 1) Put test_nospam.py in your plugin directory. 2) In config.py add test_nospam to py['load_plugins'] Then hit http://yourdomain.com/weblog/test_nospam with a browser. """ from nospam import _generateImage _template = """ nospam.py test plugin

%(test_nospam_message)s

Note: This only tests the generation of the image itself.
You'll still have to make sure that the comment plugin is installed and configured properly.

""" def _writeImage(request, number): image = _generateImage(number) response = request.getResponse() response.addHeader('Content-Type', 'image/png') image.save(response, "PNG") def cb_handle(args): request = args['request'] http = request.getHttp() config = request.getConfiguration() path_info = http["PATH_INFO"] if path_info.endswith("/test_nospam.png"): form = request.getForm() test_nospam_number = form.getvalue("test_nospam_number", None) _writeImage(request, test_nospam_number) # return True to tell pyblosxom that the request has been taken care of return 1 elif path_info.endswith("/test_nospam"): form = request.getForm() test_nospam_number = form.getvalue("test_nospam_number", None) if test_nospam_number is not None: test_nospam_message = "

You entered: %s

" % test_nospam_number else: test_nospam_message = "" result = _template % {"base_url": config["base_url"], "test_nospam_message": test_nospam_message, "test_nospam_number": test_nospam_number} response = request.getResponse() response.addHeader("Content-type", "text/html") response.addHeader("Content-length", "%d" % len(result)) response.write(result) # return True to tell pyblosxom that the request has been taken care of return 1