If you want to use the request inside a streamed response you can do
something like:
@expose()
def stream(self):
def output_pause(req):
num = 0
while 1:
num += 1
yield '%s/%s<br/>' % (req.path_info, num)
time.sleep(1)
return output_pause(request._current_obj())
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/VKSZodbWJkUJ.
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.
Anyway, even if you enable streaming in RegistryManager you won't be able
to stream the response as the debug middlewares and extensions try to read it.
You must set debug at false in development.ini to make streaming work reliably.
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/UkJdx45qXL8J.
You can report the bugs into https://sourceforge.net/p/turbogears2/tickets/
Anyway, even if you enable streaming in RegistryManager you won't be able
to stream the response as the debug middlewares and extensions try to read it.You must set debug at false in development.ini to make streaming work reliably.
Well, that is the reason why I passed request._current_obj() as
argument to the generator in my code sample.
It solves the issue of being able to access the request and identity.
Other issues are related to the fact that you have to remove, flush
and commit the DBSession yourself.
Well, that is the reason why I passed request._current_obj() as
argument to the generator in my code sample.
It solves the issue of being able to access the request and identity.
Other issues are related to the fact that you have to remove, flush
and commit the DBSession yourself.