Hello,

So I have looked further into making an internal requests with webob using 
get_response within the controller of turbogears. I have set up a minimal 
server using the documentation on the turbogears front page 
(http://turbogears.org/). I also added one expose function to make a 
request to the index. 

from wsgiref.simple_server import make_server
from tg import expose, TGController, AppConfig
from tg import response, request
from webob import Request

class RootController(TGController):
    
     @expose()
     def index(self):
         return "<h1>Hello World</h1>"
     
     @expose()
     def test(self):
        from webob import Request

        # Try to route internally
        r = 'http://localhost:8080/index'
        req = request.blank(r)
        resp = req.get_response(wsgi_app)
        tg.response.headers['content-type'] = 'text/xml'
        return '<resource>This is a test</resource>'

config = AppConfig(minimal=True, root_controller=RootController())
print "Serving on port 8080..."
wsgi_app = config.make_wsgi_app()
httpd = make_server('', 8080, wsgi_app)
httpd.serve_forever()

Again when make a GET request to http:\\localhost:8080\test the 
content-type is not set for the response. Also an AssertionError show below 
is returned on the server.

 AssertionError: The object popped (<tg.wsgiapp.RequestLocals object at 
0x000000000372F4A8>) is not the same as the object expected 
(<tg.wsgiapp.RequestLocals object at 0x00000000036F0358>)

I take it from all of these issues making an internal request is not 
feasible using get_response with the wsgi app. If that is the case, is 
there a way to make an internal request within the controller or if I can 
pass a lower level in the Turbogears stack to avoid these issues?

Thank you
- Chris

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to