On Wed, Jul 31, 2013 at 10:20 AM, Rob <[email protected]> wrote:
> Using TG v2.2.2 I am trying to access the beaker cache from a custom > middleware object but I'm getting an error: > "TypeError: No object (name: cache) has been registered for this thread." > > As per the docs, I am using `wrap_app` in the construction of > `make_base_app` > Stripped down to its bare essentials, I have: > > > Hi, when using WSGI Middlewares you are constrained to the WSGI environment. WSGI middlewares wrap around the TG application and so everything which is available inside TG itself like the TurboGears Context (tg.request/response/cache), Request and Response objects and so on are not available. To cope with this issue, TG2.3 introduced application wrappers. They are much like WSGI middlewares but receive a TurboGears Context as parameter and are expected to return a Response object. Inside application wrappers the context is available and so tg.* objects are accessible. Application wrappers also permit to specify their ordering, so it is possible to say "run this wrapper around this other wrapper" even though they are registered at different times. You can see a simple example of application wrappers at https://github.com/TurboGears/tg2/blob/master/tests/test_configuration.py#L636 -- 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/groups/opt_out.

