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

You visited this page %(counter)d times.

The session id is: %(sid)s

Test the session (or hit reload)
Invalidate the session

""" def cb_handle(args): request = args['request'] http = request.getHttp() config = request.getConfiguration() if http['PATH_INFO'].endswith("/test_session"): form = request.getForm() session = request.getSession() if "clear" in form: session.invalidate() sid = "" test_session_counter = 0 else: sid = session.id() if "test_session_counter" in session: test_session_counter = int(session["test_session_counter"]) else: test_session_counter = 0 test_session_counter = test_session_counter +1 session["test_session_counter"] = test_session_counter session.save() result = _template % {"counter": test_session_counter, "sid": sid, "url": config["base_url"] +"/test_session"} 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