Hi Alessandro, Thanks for your response and apologies for taking such a long time getting back to you.
In this particular case, I'm aware that I'm restricted to WSGI... the methods/controllers I'm trying to construct would have to use their own webob response/request. (Which is absolutely fine!) I'm having trouble understanding how I can get access to the tg cache and I'm getting a `TypeError No object (name: cache)` -- I'm tied to TG v2.2 for the time being... Is what I'm trying to do (shown in my first post) possible?? Regards, Rob. PS. Interestingly, I found a package on github called tgext.less https://bitbucket.org/clsdaniel/tgext.less which, in and example in the readme section, gives the following: from tgext.less import LESSMiddleware from tg import cache make_base_app = base_config.setup_tg_wsgi_app(load_environment) def make_app(global_conf, full_stack=True, **app_conf): app = make_base_app(global_conf, full_stack=True, **app_conf) # LESS with beaker cache backend app = LESSMiddleware(app, cache=cache) return app But I have absolutely no idea how this example is supposed to work...! On Thursday, 1 August 2013 20:04:15 UTC+1, Alessandro Molina wrote: > > On Wed, Jul 31, 2013 at 10:20 AM, Rob <[email protected] > <javascript:>>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.

