>If you know python and you are trying to get into web page design, you will find yourself overwhelmed by the number of choices. TurboGears, Django, and Twisted all offer you access to web framework, the difficulty lies in getting them to work behind apache.
Something I have found that works great for getting my python backed web pages up and running is CherryTemplate. It is simple, you do not need to worry about setting up an WSGI, or running the server application persistently.
There are two main things that you need to be aware of: getting apache to use your CherryTemplate rendering and getting CherryTemplate to find the file.
First, decide what the file extension will be for you template files.
I use .chy for html templates and .chx for xml templates. Then you configure your .htaccess
AddHandler cherry-template .chy Action cherry-template /cgi-bin/render.py
If you know the basic understanding of handlers and such then this will make sense. If you have access you can put it into your httpd.conf. Next to use cherry template you need the file, "render.py"
#!/usr/bin/env python import os,sys import cherrytemplate epage = "/home/webserver/public_html/edocs/404.html" sys.stdout.write("Content-Type: text/html\r\n\r\n") fn = os.environ.get("PATH_TRANSLATED","") if os.path.exists(fn): sys.stdout.write(cherrytemplate.renderTemplate(file = fn)) else: sys.stdout.write(cherrytemplate.renderTemplate(file = epage))
You do not need to "install" cherrytemplate per se'. It is a stand alone python file. Download the package and put the file "cherrytemplate.py" into your cgi-bin directory. If you would prefere to put the file elsewhere, then you can add that directory to your path at runtime by including the following:
import sys sys.path.insert(0,'/home/webserver/cgi-lib')
That works really well for putting including any sort of external python. Even though you are using python you really should remember to separate church and state so to speak. (Separate you code from your template where possible).