Impossible to configure HTTP server

Bug #422679 reported by Pat Deegan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
web.py
Fix Released
Undecided
Anand Chitipothu

Bug Description

I posted to the g00gle group (http://groups.google.com/group/webpy/browse_thread/thread/96280ab488ef784d/1223d4d336fe3be9#1223d4d336fe3be9 ), to no avail so I'm submitting this here.

We really need to get access to the HTTP server prior to entering its listen/serve request loop, so we can customize and configure stuff (e.g. socket timeout). The attached patch (for web.py 0.32) provides an add_servercallback() method to web.application that allows you to do something like:

    ##### snip #####
    class test:
        def GET(self, name):
            return name

    def configure_webserver(server):
        server.timeout = 666

    urls = ("/(.*)", "test")
    app = application(urls, globals())

    app.add_servercallback(configure_webserver)

    # now, the configure_webserver function will be called whenever an HTTP server is instantiated, before it is started.
    ##### snip #####

Feel free to re-organize/rename anything, or ask me to do so, to merge this into the project.

Thanks and regards,
Pat Deegan

Revision history for this message
Pat Deegan (webpy-pat) wrote :
Revision history for this message
Anand Chitipothu (anandology) wrote :

the configure_webserver function works only for CherryPyWSIServer and not for other types of server. In fact it is not possible to write a function to configure any kind of server.

Here is the work-around: (you need latest web.py code for this)

import web

def create_server(*a, **kw):
    server = web.wsgiserver.CherryPyServer(*a, **kw)
    server.timeout = 666
    return server

web.httpserver.CherryPyServer = create_server

Changed in webpy:
status: New → Fix Committed
assignee: nobody → Anand Chitipothu (anandology)
Revision history for this message
Anand Chitipothu (anandology) wrote :

importing CheryPyWSGIServer in the beginning of web.httpserver module breaks GAE.

here is the new work-around:

import web

def create_server(server_address, wsgi_app):
    server = web.wsgiserver.CherryPyWSGIServer(server_address, wsgi_app, server_name="localhost")
    server.timeout = 666
    return server

web.httpserver.WSGIServer = create_server

Changed in webpy:
milestone: none → 0.33
Changed in webpy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.