PyBlosxom as a WSGI Application with Twisted
Dependencies
-
Twisted - The Twisted event-driven networking framework
-
Twisted Web 2: Twisted Web2 has built-in support for WSGI, which is used to connect to PyBlosxom.
The wsgi_app.py file from the PyBlosxom source ./pyblosxom-1.3.2/web directory
General Setup
- Install the Twisted and Twisted Web 2 packages.
- Create a directory for all of your configuration and run-time files.
- Copy web/wsgi_app.py from the PyBlosxom distribution in the directory.
- Copy the config.py PyBlosxom configuration file into the directory as well, making any customizations that are needed.
Twisted Configuration
Use a .tac file for the Twisted server configuration. A .tac file is simply a set of Python code required to set up the server and its parameters. Here is the .tac configuration in this presentation demo:
# # michipug.tac for pyblosxom presentation # from twisted.application import service, strports from twisted.web2 import server, channel, wsgi from twisted.web2.channel import http from wsgi_app import application as pyblosxom_application pyBlosxomResource = wsgi.WSGIResource(pyblosxom_application) site = server.Site(pyBlosxomResource) application = service.Application('web') s = strports.service('tcp:9001', channel.HTTPFactory(site)) s.setServiceParent(application)
Note: the TCP port is 9001
Startup Script
Here is the script from this presentation demo:
#!/bin/bash set -v twistd -noy michipug.tac A more production ready approach might be something like the following: twistd -y michipug.tac --pidfile=michipug.pid --logfile=michipug.log
Run it.
$ ./start.sh
[23:22] | [] | #-permalink-#