[Twisted-Python] Twisted.Web and Perl CGIs

Patrick K. O'Brien pobrien at orbtech.com
Mon May 19 17:05:25 EDT 2003

I'm having trouble getting a Twisted.Web configured properly to work
with some Perl CGI scripts.  The Perl scripts are part of SQL-Ledger,
and their instructions are for Apache, but I'm hoping to using Twisted
instead of Apache.

To begin, they suggest the following for http.conf, and I'm not sure
how to go about creating the equivalent environment with Twisted:

create a file sql-ledger-httpd.conf in the same location
where your httpd.conf is and copy the next section into the file

  Alias /sql-ledger/ /usr/local/sql-ledger/
  <Directory /usr/local/sql-ledger>
    AddHandler cgi-script .pl
    Options ExecCGI Includes FollowSymlinks

  <Directory /usr/local/sql-ledger/users>
    Order Deny,Allow
    Deny from All

edit httpd.conf and add

  # SQL-Ledger
  Include <ServerRoot>/sql-ledger-httpd.conf

Note: Replace <ServerRoot> with the server's root directory!

restart your web server.

I think the need for FollowSymlinks is what's causing me problems when
I try to create a .rpy file that allows Perl CGIs.  I've tried several
variations of the .rpy file from the Twisted documentation, but can't
get one that works.  Here is where I gave up:

from twisted.web import static, twcgi

class PerlScript(twcgi.FilteredScript):
    filter = '/usr/bin/perl' # Points to the perl parser

resource = static.File("/sql-ledger") # Points to the perl website
resource.processors = {".pl": PerlScript} # Files that end with .pl will be
                                          # processed by PerlScript
resource.indexNames = ['admin.pl']

I think one of the problems (besides the fact that I don't know
Twisted well enough) is that the admin.pl script is actually a symlink
to login.pl.  Would that be a problem?  I also don't understand what I
should be pointing to as a parameter to static.File().

Any help would be greatly appreciated.  The SQL-Ledger installation
instructions are here, in case that helps:




Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
"Your source for Python programming expertise."

More information about the Twisted-Python mailing list