Jay directed my attention to Twisted.web.
Twisted is a networking engine written in Python, supporting numerous protocols. It contains a web server, numerous chat clients, chat servers, mail servers, and more. Twisted is made up of a number of sub-projects which can be accessed individually through the twisted projects index.
Twisted Web is a web application server written in pure Python, with APIs at multiple levels of abstraction to facilitate different kinds of web programming. ... [It] provides a simple, stable resource publishing API, on top of an HTTP/1.0 server implementation with some HTTP/1.1 features.
Publishing an arbitrary web directory was a breeze using the preconfigured web server. I just had to create a
web.tap file, and start the server:
[lsc@home ~]$ mktap web --path /path/to/web/dir
[lsc@home ~]$ twistd -f web.tab

While this does not yet meet the requirements of my intended project,
Twisted has caught my attention.
Glancing through the
HOWTOs, I was thrilled by the rich set of APIs that made network application programming a breeze (really?). Apart from the core which provides utilities for asynchronous network programming, authentication, DB interfaces, unit testion, etc, there's a host of sub
projects which provide convenient protocol implementations for Web, SSH, Mail, IRC/IM, DNS, and such.
# Within a few minutes, I had my first 'server' running
from twisted.internet import protocol, reactor
from twisted.protocols import basic
from sys import stdout
class ParrotProtocol(basic.LineReceiver):
def connectionMade(self):
stdout.write("Polly found a friend\r\n")
self.sendLine("Polly wants a cracker")
def lineReceived(self, line):
if line == "cracker":
self.sendLine("Thank you!")
self.transport.loseConnection()
else:
self.sendLine("Aark!! %s" % (line))
def connectionLost(self, reason):
stdout.write("Polly lost a friend\r\n")
self.sendLine("Bye bye!")
#/end class ParrotProtocol
f = protocol.Factory()
f.protocol = ParrotProtocol
reactor.listenTCP(8888, f)
reactor.run()
Nice. This thingamagic seems like something worth investing some time in.
I've earmarked several packages/modules which might come in handy:
*
twisted.python.usage*
twisted.cred*
twisted.spread*
twisted.web[update]Twisted by name, twisted by nature.
Naming convention used in some of the packages are a little OTT.
Eg. In the spreadable (distributed) computing package --
twisted.speadbanana...
jelly...
flavors... InsecureJelly... Unjellyable...
Amusing? For a while. Meaningful? Hmmmm...
Documentation is very extensive, which is great. However, there were sections of the tutorials which took quantum leaps rather than steps. Perhaps it's just due to my limited experience with python and proper program design, but I had trouble progressing from
step 3 to
step 4 without first groping in the dark (Enlightenment was found in the
twisted.python.components tutorial).
Stumbled upon similar speedbumps in latter steps where things magically appeared warranting further scouring for the associated documentation.
Patience...
[/update][update2]Useful
article[/update2]