[Twisted-Python] distrib.UserDirectory improvements
hi, moshez suggested me to extend distrib.UserDirectory for my needs. attached is what i am using right now. i hope to integrate this into distrib.py for cvs, later. please give me feedback! paul
Hello, I'm just getting started with twisted and have a question about twisted web. How would I go about limiting the web server to accepting a single connection? I know you might be asking your self why anyone would want to do such a stupid thing, but I'm controlling some hardware and need to restrict access to it to a single user at a time. Anyway, I'd appreciate any pointers. :-) Cheers, don
On Tue, Jun 17, 2003 at 05:10:55PM -0500, Don Hiatt wrote:
Hello,
I'm just getting started with twisted and have a question about twisted web. How would I go about limiting the web server to accepting a single connection? I know you might be asking your self why anyone would want to do such a stupid thing, but I'm controlling some hardware and need to restrict access to it to a single user at a time.
Anyway, I'd appreciate any pointers. :-)
You'll probably have to subclass twisted.web.server.Site to make buildProtocol return None if a connection is active. Untested code from the top of my head: from twisted.protocols.http import HTTPChannel from twisted.web.server import Site class SingleConnectionHTTPChannel(HTTPChannel): def connectionLost(self, reason): self.factory.connections -= 1 HTTPChannel.connectionLost(self, reason) class SingleConnectionSite(Site): protocol = SingleConnectionHTTPChannel connections = 0 def buildProtocol(self, addr): # Reject concurrent connections if self.connections: return None self.connections += 1 return Site.buildProtocol(self, addr) -Andrew.
participants (3)
-
Andrew Bennetts
-
Don Hiatt
-
Paul Boehm