capture uwsgi start_response

Skip to first unread message

Emanuel Vitorino

Feb 1, 2021, 8:09:40 AM2/1/21
to cherrypy-users
Hi all

I'm making some changes in an old application that uses trac edgewall, being my first interaction with trac and CherryPy

The thing is, the application that is on production now is something like this:

def application(environ, start_response):
     if something():  # this is just an example
         start_response('301 Moved Permanently', [('Location', '')])
         return []
        return trac.web.main.dispatch_request(environ, start_response)

trac.web.main.dispatch_request is the trac wsgi application

But now, I need to put a cherrypy application in the middle so:

def application(environ, start_response):
    root = Trac()
    root.openid = Auth()
    cherrypy.tree.mount(root, "/", config=conf)
    return cherrypy.tree(environ, start_response)

And this works until the part that I must gave control to trac.web.main.dispatch_request
Inside cherrypy objects I cannot find start_response callback

And doing something like:

env = None
sr = None

class Trac():
    def index(self):
         return trac.web.main.dispatch_request(env, sr)

def application(environ, start_response):
    env = environ
    sr = start_response
    root = Trac()
    root.openid = Auth()
    cherrypy.tree.mount(root, "/", config=conf)
    return cherrypy.tree(environ, start_response)

Also don't work throwing an error that response headers already been started.

Any ideas how to I can capture start_response inside my CP application

Thank you in advance

Kind regards,

Sviatoslav Sydorenko

Feb 1, 2021, 12:38:37 PM2/1/21
пн, 1 лют. 2021, 14:09 користувач Emanuel Vitorino <> пише:
Any ideas how to I can capture start_response inside my CP application

Why don't you just mount Trac's WSGI app in the tree under some dedicated URL?


Sent from my phone, please pardon any typos. 

Emanuel Vitorino

Feb 8, 2021, 10:08:57 AM2/8/21

Thanks for your answer.

I've tried but still don't work.

I receive:
return child[key]
TypeError: 'Response' object does not support indexing

Any other idea? :)

You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Tim Roberts

Feb 8, 2021, 12:24:04 PM2/8/21
to cherrypy-users
That tells us nothing about what code you added or where you added it.  Show us your new code, and someone can help.

Tim Roberts

Reply all
Reply to author
0 new messages