Changeset 32:0bd397459063
- Timestamp:
- 02/23/06 16:16:01
(2 years ago)
- Author:
- Allan Saddi <allan@saddi.com>
- branch:
- default
- convert_revision:
- svn:46762da8-4eb7-0310-94e9-d918b60927c8/flup/trunk@1839
- Message:
Add paste.server_factory-compliant factories and respective
egg entry points. Add debug option to servers, which is True
by default.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r31 |
r32 |
|
| | 1 | 2006-02-23 Allan Saddi <asaddi@kalahari.flup.org> |
|---|
| | 2 | |
|---|
| | 3 | * Add paste.server_factory-compliant factories and respective |
|---|
| | 4 | egg entry points. Thanks to Luis Bruno for the code. |
|---|
| | 5 | |
|---|
| | 6 | Add debug option to servers, which is True by default. |
|---|
| | 7 | Currently, only server-level error handling is affected. |
|---|
| | 8 | |
|---|
| 1 | 9 | 2006-01-15 Allan Saddi <asaddi@ganymede.saddi.net> |
|---|
| 2 | 10 | |
|---|
| r16 |
r32 |
|
| 1 | | # Copyright (c) 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 104 | 104 | multithreaded=True, multiprocess=False, |
|---|
| 105 | 105 | bindAddress=('localhost', 8009), allowedServers=None, |
|---|
| 106 | | loggingLevel=logging.INFO, **kw): |
|---|
| | 106 | loggingLevel=logging.INFO, debug=True, **kw): |
|---|
| 107 | 107 | """ |
|---|
| 108 | 108 | scriptName is the initial portion of the URL path that "belongs" |
|---|
| … | … | |
| 132 | 132 | bindAddress=bindAddress, |
|---|
| 133 | 133 | allowedServers=allowedServers, |
|---|
| 134 | | loggingLevel=loggingLevel) |
|---|
| | 134 | loggingLevel=loggingLevel, |
|---|
| | 135 | debug=debug) |
|---|
| 135 | 136 | for key in ('jobClass', 'jobArgs'): |
|---|
| 136 | 137 | if kw.has_key(key): |
|---|
| … | … | |
| 161 | 162 | |
|---|
| 162 | 163 | return ret |
|---|
| | 164 | |
|---|
| | 165 | def factory(global_conf, host=None, port=None, **local): |
|---|
| | 166 | import paste_factory |
|---|
| | 167 | return paste_factory.helper(WSGIServer, global_conf, host, port, **local) |
|---|
| 163 | 168 | |
|---|
| 164 | 169 | if __name__ == '__main__': |
|---|
| r17 |
r32 |
|
| 1 | | # Copyright (c) 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 755 | 755 | multithreaded=True, multiprocess=False, |
|---|
| 756 | 756 | bindAddress=('localhost', 8009), allowedServers=NoDefault, |
|---|
| 757 | | loggingLevel=logging.INFO): |
|---|
| | 757 | loggingLevel=logging.INFO, debug=True): |
|---|
| 758 | 758 | """ |
|---|
| 759 | 759 | scriptName is the initial portion of the URL path that "belongs" |
|---|
| … | … | |
| 790 | 790 | self.multithreaded = multithreaded |
|---|
| 791 | 791 | self.multiprocess = multiprocess |
|---|
| | 792 | self.debug = debug |
|---|
| 792 | 793 | self._bindAddress = bindAddress |
|---|
| 793 | 794 | if allowedServers is NoDefault: |
|---|
| … | … | |
| 927 | 928 | all errors should be caught at the application level. |
|---|
| 928 | 929 | """ |
|---|
| 929 | | request.startResponse(200, 'OK', [('Content-Type', 'text/html')]) |
|---|
| 930 | | import cgitb |
|---|
| 931 | | request.write(cgitb.html(sys.exc_info())) |
|---|
| | 930 | if self.debug: |
|---|
| | 931 | request.startResponse(200, 'OK', [('Content-Type', 'text/html')]) |
|---|
| | 932 | import cgitb |
|---|
| | 933 | request.write(cgitb.html(sys.exc_info())) |
|---|
| | 934 | else: |
|---|
| | 935 | errorpage = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
|---|
| | 936 | <html><head> |
|---|
| | 937 | <title>Unhandled Exception</title> |
|---|
| | 938 | </head><body> |
|---|
| | 939 | <h1>Unhandled Exception</h1> |
|---|
| | 940 | <p>An unhandled exception was thrown by the application.</p> |
|---|
| | 941 | </body></html> |
|---|
| | 942 | """ |
|---|
| | 943 | request.startResponse(200, 'OK', [('Content-Type', 'text/html')]) |
|---|
| | 944 | request.write(errorpage) |
|---|
| r16 |
r32 |
|
| 1 | | # Copyright (c) 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 103 | 103 | def __init__(self, application, scriptName='', environ=None, |
|---|
| 104 | 104 | bindAddress=('localhost', 8009), allowedServers=None, |
|---|
| 105 | | loggingLevel=logging.INFO, **kw): |
|---|
| | 105 | loggingLevel=logging.INFO, debug=True, **kw): |
|---|
| 106 | 106 | """ |
|---|
| 107 | 107 | scriptName is the initial portion of the URL path that "belongs" |
|---|
| … | … | |
| 131 | 131 | bindAddress=bindAddress, |
|---|
| 132 | 132 | allowedServers=allowedServers, |
|---|
| 133 | | loggingLevel=loggingLevel) |
|---|
| | 133 | loggingLevel=loggingLevel, |
|---|
| | 134 | debug=debug) |
|---|
| 134 | 135 | for key in ('multithreaded', 'multiprocess', 'jobClass', 'jobArgs'): |
|---|
| 135 | 136 | if kw.has_key(key): |
|---|
| … | … | |
| 159 | 160 | |
|---|
| 160 | 161 | return ret |
|---|
| | 162 | |
|---|
| | 163 | def factory(global_conf, host=None, port=None, **local): |
|---|
| | 164 | import paste_factory |
|---|
| | 165 | return paste_factory.helper(WSGIServer, global_conf, host, port, **local) |
|---|
| 161 | 166 | |
|---|
| 162 | 167 | if __name__ == '__main__': |
|---|
| r14 |
r32 |
|
| 1 | | # Copyright (c) 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 64 | 64 | def __init__(self, application, environ=None, |
|---|
| 65 | 65 | multithreaded=True, multiprocess=False, |
|---|
| 66 | | bindAddress=None, multiplexed=False, **kw): |
|---|
| | 66 | bindAddress=None, multiplexed=False, |
|---|
| | 67 | debug=True, **kw): |
|---|
| 67 | 68 | """ |
|---|
| 68 | 69 | environ, if present, must be a dictionary-like object. Its |
|---|
| … | … | |
| 84 | 85 | multiprocess=multiprocess, |
|---|
| 85 | 86 | bindAddress=bindAddress, |
|---|
| 86 | | multiplexed=multiplexed) |
|---|
| | 87 | multiplexed=multiplexed, |
|---|
| | 88 | debug=debug) |
|---|
| 87 | 89 | for key in ('jobClass', 'jobArgs'): |
|---|
| 88 | 90 | if kw.has_key(key): |
|---|
| … | … | |
| 112 | 114 | |
|---|
| 113 | 115 | return ret |
|---|
| | 116 | |
|---|
| | 117 | def factory(global_conf, host=None, port=None, **local): |
|---|
| | 118 | import paste_factory |
|---|
| | 119 | return paste_factory.helper(WSGIServer, global_conf, host, port, **local) |
|---|
| 114 | 120 | |
|---|
| 115 | 121 | if __name__ == '__main__': |
|---|
| r24 |
r32 |
|
| 1 | | # Copyright (c) 2002, 2003, 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2002, 2003, 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 900 | 900 | def __init__(self, application, environ=None, |
|---|
| 901 | 901 | multithreaded=True, multiprocess=False, |
|---|
| 902 | | bindAddress=None, multiplexed=False): |
|---|
| | 902 | bindAddress=None, multiplexed=False, |
|---|
| | 903 | debug=True): |
|---|
| 903 | 904 | """ |
|---|
| 904 | 905 | bindAddress, if present, must either be a string or a 2-tuple. If |
|---|
| … | … | |
| 925 | 926 | self.multithreaded = multithreaded |
|---|
| 926 | 927 | self.multiprocess = multiprocess |
|---|
| | 928 | self.debug = debug |
|---|
| 927 | 929 | |
|---|
| 928 | 930 | self._bindAddress = bindAddress |
|---|
| … | … | |
| 1136 | 1138 | should be overridden. |
|---|
| 1137 | 1139 | """ |
|---|
| 1138 | | import cgitb |
|---|
| 1139 | | req.stdout.write('Content-Type: text/html\r\n\r\n' + |
|---|
| 1140 | | cgitb.html(sys.exc_info())) |
|---|
| | 1140 | if self.debug: |
|---|
| | 1141 | import cgitb |
|---|
| | 1142 | req.stdout.write('Content-Type: text/html\r\n\r\n' + |
|---|
| | 1143 | cgitb.html(sys.exc_info())) |
|---|
| | 1144 | else: |
|---|
| | 1145 | errorpage = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
|---|
| | 1146 | <html><head> |
|---|
| | 1147 | <title>Unhandled Exception</title> |
|---|
| | 1148 | </head><body> |
|---|
| | 1149 | <h1>Unhandled Exception</h1> |
|---|
| | 1150 | <p>An unhandled exception was thrown by the application.</p> |
|---|
| | 1151 | </body></html> |
|---|
| | 1152 | """ |
|---|
| | 1153 | req.stdout.write('Content-Type: text/html\r\n\r\n' + |
|---|
| | 1154 | errorpage) |
|---|
| r14 |
r32 |
|
| 1 | | # Copyright (c) 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 64 | 64 | """ |
|---|
| 65 | 65 | def __init__(self, application, environ=None, |
|---|
| 66 | | bindAddress=None, multiplexed=False, **kw): |
|---|
| | 66 | bindAddress=None, multiplexed=False, |
|---|
| | 67 | debug=True, **kw): |
|---|
| 67 | 68 | """ |
|---|
| 68 | 69 | environ, if present, must be a dictionary-like object. Its |
|---|
| … | … | |
| 84 | 85 | multiprocess=True, |
|---|
| 85 | 86 | bindAddress=bindAddress, |
|---|
| 86 | | multiplexed=multiplexed) |
|---|
| | 87 | multiplexed=multiplexed, |
|---|
| | 88 | debug=debug) |
|---|
| 87 | 89 | for key in ('multithreaded', 'multiprocess', 'jobClass', 'jobArgs'): |
|---|
| 88 | 90 | if kw.has_key(key): |
|---|
| … | … | |
| 129 | 131 | return ret |
|---|
| 130 | 132 | |
|---|
| | 133 | def factory(global_conf, host=None, port=None, **local): |
|---|
| | 134 | import paste_factory |
|---|
| | 135 | return paste_factory.helper(WSGIServer, global_conf, host, port, **local) |
|---|
| | 136 | |
|---|
| 131 | 137 | if __name__ == '__main__': |
|---|
| 132 | 138 | def test_app(environ, start_response): |
|---|
| r14 |
r32 |
|
| 1 | | # Copyright (c) 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 91 | 91 | multithreaded=True, multiprocess=False, |
|---|
| 92 | 92 | bindAddress=('localhost', 4000), allowedServers=None, |
|---|
| 93 | | loggingLevel=logging.INFO, **kw): |
|---|
| | 93 | loggingLevel=logging.INFO, debug=True, **kw): |
|---|
| 94 | 94 | """ |
|---|
| 95 | 95 | scriptName is the initial portion of the URL path that "belongs" |
|---|
| … | … | |
| 119 | 119 | bindAddress=bindAddress, |
|---|
| 120 | 120 | allowedServers=allowedServers, |
|---|
| 121 | | loggingLevel=loggingLevel) |
|---|
| | 121 | loggingLevel=loggingLevel, |
|---|
| | 122 | debug=debug) |
|---|
| 122 | 123 | for key in ('jobClass', 'jobArgs'): |
|---|
| 123 | 124 | if kw.has_key(key): |
|---|
| … | … | |
| 148 | 149 | |
|---|
| 149 | 150 | return ret |
|---|
| | 151 | |
|---|
| | 152 | def factory(global_conf, host=None, port=None, **local): |
|---|
| | 153 | import paste_factory |
|---|
| | 154 | return paste_factory.helper(WSGIServer, global_conf, host, port, **local) |
|---|
| 150 | 155 | |
|---|
| 151 | 156 | if __name__ == '__main__': |
|---|
| r17 |
r32 |
|
| 1 | | # Copyright (c) 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 274 | 274 | multithreaded=True, multiprocess=False, |
|---|
| 275 | 275 | bindAddress=('localhost', 4000), allowedServers=NoDefault, |
|---|
| 276 | | loggingLevel=logging.INFO): |
|---|
| | 276 | loggingLevel=logging.INFO, debug=True): |
|---|
| 277 | 277 | """ |
|---|
| 278 | 278 | scriptName is the initial portion of the URL path that "belongs" |
|---|
| … | … | |
| 309 | 309 | self.multithreaded = multithreaded |
|---|
| 310 | 310 | self.multiprocess = multiprocess |
|---|
| | 311 | self.debug = debug |
|---|
| 311 | 312 | self._bindAddress = bindAddress |
|---|
| 312 | 313 | if allowedServers is NoDefault: |
|---|
| … | … | |
| 469 | 470 | all errors should be caught at the application level. |
|---|
| 470 | 471 | """ |
|---|
| 471 | | import cgitb |
|---|
| 472 | | request.stdout.write('Content-Type: text/html\r\n\r\n' + |
|---|
| 473 | | cgitb.html(sys.exc_info())) |
|---|
| | 472 | if self.debug: |
|---|
| | 473 | import cgitb |
|---|
| | 474 | request.stdout.write('Content-Type: text/html\r\n\r\n' + |
|---|
| | 475 | cgitb.html(sys.exc_info())) |
|---|
| | 476 | else: |
|---|
| | 477 | errorpage = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
|---|
| | 478 | <html><head> |
|---|
| | 479 | <title>Unhandled Exception</title> |
|---|
| | 480 | </head><body> |
|---|
| | 481 | <h1>Unhandled Exception</h1> |
|---|
| | 482 | <p>An unhandled exception was thrown by the application.</p> |
|---|
| | 483 | </body></html> |
|---|
| | 484 | """ |
|---|
| | 485 | request.stdout.write('Content-Type: text/html\r\n\r\n' + |
|---|
| | 486 | errorpage) |
|---|
| r14 |
r32 |
|
| 1 | | # Copyright (c) 2005 Allan Saddi <allan@saddi.com> |
|---|
| | 1 | # Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> |
|---|
| 2 | 2 | # All rights reserved. |
|---|
| 3 | 3 | # |
|---|
| … | … | |
| 90 | 90 | def __init__(self, application, scriptName='', environ=None, |
|---|
| 91 | 91 | bindAddress=('localhost', 4000), allowedServers=None, |
|---|
| 92 | | loggingLevel=logging.INFO, **kw): |
|---|
| | 92 | loggingLevel=logging.INFO, debug=True, **kw): |
|---|
| 93 | 93 | """ |
|---|
| 94 | 94 | scriptName is the initial portion of the URL path that "belongs" |
|---|
| … | … | |
| 118 | 118 | bindAddress=bindAddress, |
|---|
| 119 | 119 | allowedServers=allowedServers, |
|---|
| 120 | | loggingLevel=loggingLevel) |
|---|
| | 120 | loggingLevel=loggingLevel, |
|---|
| | 121 | debug=debug) |
|---|
| 121 | 122 | for key in ('multithreaded', 'multiprocess', 'jobClass', 'jobArgs'): |
|---|
| 122 | 123 | if kw.has_key(key): |
|---|
| … | … | |
| 146 | 147 | |
|---|
| 147 | 148 | return ret |
|---|
| | 149 | |
|---|
| | 150 | def factory(global_conf, host=None, port=None, **local): |
|---|
| | 151 | import paste_factory |
|---|
| | 152 | return paste_factory.helper(WSGIServer, global_conf, host, port, **local) |
|---|
| 148 | 153 | |
|---|
| 149 | 154 | if __name__ == '__main__': |
|---|
| r26 |
r32 |
|
| 1 | 1 | #!/usr/bin/env python |
|---|
| | 2 | |
|---|
| | 3 | setuptools_extras = {} |
|---|
| 2 | 4 | |
|---|
| 3 | 5 | try: |
|---|
| 4 | 6 | from setuptools import setup |
|---|
| | 7 | setuptools_extras['entry_points'] = """ |
|---|
| | 8 | [paste.server_factory] |
|---|
| | 9 | ajp = flup.server.ajp:factory |
|---|
| | 10 | fcgi = flup.server.fcgi:factory |
|---|
| | 11 | scgi = flup.server.scgi:factory |
|---|
| | 12 | ajp_fork = flup.server.ajp_fork:factory |
|---|
| | 13 | fcgi_fork = flup.server.fcgi_fork:factory |
|---|
| | 14 | scgi_fork = flup.server.scgi_fork:factory |
|---|
| | 15 | """ |
|---|
| 5 | 16 | except ImportError: |
|---|
| 6 | 17 | from distutils.core import setup |
|---|
| … | … | |
| 12 | 23 | author_email='allan@saddi.com', |
|---|
| 13 | 24 | url='http://www.saddi.com/software/flup/', |
|---|
| 14 | | packages=['flup', 'flup.middleware', 'flup.resolver', 'flup.server']) |
|---|
| | 25 | packages=['flup', 'flup.middleware', 'flup.resolver', 'flup.server'], |
|---|
| | 26 | **setuptools_extras) |
|---|