Python Cleanup
RESTLog Server Version 0.3
also contains fixes for another item on my To Do list.
The Python code has been refactored so that RESTLog.cgi only contains
customization information and calls out to libraries for functionality. This allows
the libraries to be located in a common location. This makes the deployment
of new versions of RESTLog on sites with RESTLog installed across multiple directories
easier. The new RESTLog.cgi is vastly simplified:
import cgitb; cgitb.enable()
import RESTLogImpl
RESTLogImpl.data_dir__ = "./data/"
RESTLogImpl.template_file_name__ = "template.html"
RESTLogImpl.RESTLogMain()
Now the only thing left to do is tell Python where to find the libraries. This can be done through the .htacces file if you are running under Apache:
SetEnv PYTHONPATH "c:\sw_dev\RESTLogServer"
This allows each script to be customized without the need to
have mutiple copies of the other Python files lying around.
The template_file_name__ points to the file that contains the HTML
template. Here on WellFormedWeb.org I have two scripts running; one under
/RESTLog.cgi and the other at /stories/RESTLog.cgi.
They have their template_file_name__
set to "template.html" and "../template.html" respectively. This means
that both of the scripts refer to the same template file. Changes to the template
of one location will be reflected at both /RESTLog.cgi and
/stories/RESTLog.cgi. I could let them have their
own individual templates by setting them both to "template.html".
That would allow me to completely change the formatting for weblog entries
versus stories.