Skip to content

Commit

Permalink
git-svn-id: svn://cherokee-project.com/cherokee-pyscgi@517 5dc97367-9…
Browse files Browse the repository at this point in the history
…7f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Dec 12, 2006
1 parent 2d94078 commit ef95578
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
@@ -1,3 +1,14 @@
2006-12-12 Alvaro Lopez Ortega <alvaro@alobbs.com>

* tests/test1_env.py, tests/test2_post.py: Updated for using
ServerFactory.

* pyscgi/pyscgi.py: Added new SCGIServerFork class implementing a
forking server. So far I had only a Thread based one.

* pyscgi/pyscgi.py (ServerFactory): Added a new factory function
to instance servers.

2006-12-10 Alvaro Lopez Ortega <alvaro@alobbs.com> 2006-12-10 Alvaro Lopez Ortega <alvaro@alobbs.com>


* pyscgi/pyscgi.py, tests/test1_env.py, tests/test2_post.py: First * pyscgi/pyscgi.py, tests/test1_env.py, tests/test2_post.py: First
Expand Down
14 changes: 13 additions & 1 deletion pyscgi/pyscgi.py
Expand Up @@ -103,4 +103,16 @@ def handle_request (self):
class SCGIServer(SocketServer.ThreadingTCPServer): class SCGIServer(SocketServer.ThreadingTCPServer):
def __init__(self, handler_class=SCGIHandler, host="", port=4000): def __init__(self, handler_class=SCGIHandler, host="", port=4000):
self.allow_reuse_address = True self.allow_reuse_address = True
SocketServer.TCPServer.__init__ (self, (host, port), handler_class) SocketServer.ThreadingTCPServer.__init__ (self, (host, port), handler_class)

class SCGIServerFork (SocketServer.ForkingTCPServer):
def __init__(self, handler_class=SCGIHandler, host="", port=4000):
self.allow_reuse_address = True
SocketServer.ForkingTCPServer.__init__ (self, (host, port), handler_class)


def ServerFactory (threading=False, *args, **kargs):
if threading:
return SCGIServer(*args, **kargs)
else:
return SCGIServerFork(*args, **kargs)
4 changes: 2 additions & 2 deletions tests/test1_env.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python


from pyscgi import SCGIHandler, SCGIServer from pyscgi import ServerFactory, SCGIHandler


DEFAULT_PORT = 4000 DEFAULT_PORT = 4000


Expand All @@ -20,7 +20,7 @@ def handle_request (self):
self.print_env() self.print_env()


def main(): def main():
srv = SCGIServer(handler_class=MyHandler, port=DEFAULT_PORT) srv = ServerFactory(handler_class=MyHandler, port=DEFAULT_PORT)
srv.serve_forever() srv.serve_forever()


if __name__ == "__main__": if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tests/test2_post.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python


from pyscgi import SCGIHandler, SCGIServer from pyscgi import SCGIHandler, ServerFactory


DEFAULT_PORT = 4000 DEFAULT_PORT = 4000
POST_EXAMPLE = """ POST_EXAMPLE = """
Expand Down Expand Up @@ -36,7 +36,7 @@ def handle_request (self):
self.output.write(POST_EXAMPLE) self.output.write(POST_EXAMPLE)


def main(): def main():
srv = SCGIServer(handler_class=MyHandler, port=DEFAULT_PORT) srv = ServerFactory(handler_class=MyHandler, port=DEFAULT_PORT)
srv.serve_forever() srv.serve_forever()


if __name__ == "__main__": if __name__ == "__main__":
Expand Down

0 comments on commit ef95578

Please sign in to comment.