capture uwsgi start_response

Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

capture uwsgi start_response

Emanuel-25
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:

wsgi.py

def application(environ, start_response):
     if something():  # this is just an example
         start_response('301 Moved Permanently', [('Location', 'http://google.com')])
         return []
    else:
        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():
    @cherrypy.expose
    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,
Emanuel

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/804892e9-40ca-4c97-a132-144727e78318n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: capture uwsgi start_response

Sviatoslav Sydorenko (@webknjaz)
пн, 1 лют. 2021, 14:09 користувач Emanuel Vitorino <[hidden email]> пише:
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?


--Sviatoslav.

Sent from my phone, please pardon any typos. 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/CAFYONRCxrNHfDd0ybDCSnqSThdPUAVs%3DQUJgKC%2Bc9tnM6%2BZARw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: capture uwsgi start_response

Emanuel-25
Hi

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? :)
Thanks,
Emanuel

Sviatoslav Sydorenko <[hidden email]> escreveu no dia segunda, 1/02/2021 à(s) 17:38:
пн, 1 лют. 2021, 14:09 користувач Emanuel Vitorino <[hidden email]> пише:
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?


--Sviatoslav.

Sent from my phone, please pardon any typos. 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/CAFYONRCxrNHfDd0ybDCSnqSThdPUAVs%3DQUJgKC%2Bc9tnM6%2BZARw%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/CAAFV6wOYB_LbX-r3tr%2B%3DW2XkWfmcc%3DTBhmByJNFqCN%2BHiFdV0A%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: capture uwsgi start_response

Tim Roberts
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

On Monday, February 8, 2021 at 7:08:57 AM UTC-8 [hidden email] wrote:
Hi

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? :)
Thanks,
Emanuel

Sviatoslav Sydorenko <[hidden email]> escreveu no dia segunda, 1/02/2021 à(s) 17:38:
пн, 1 лют. 2021, 14:09 користувач Emanuel Vitorino <[hidden email]> пише:
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?


--Sviatoslav.

Sent from my phone, please pardon any typos. 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/CAFYONRCxrNHfDd0ybDCSnqSThdPUAVs%3DQUJgKC%2Bc9tnM6%2BZARw%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/4e8bba9f-5271-4681-8056-b0cf5316fdc9n%40googlegroups.com.