On Fri, 2011-06-03 at 09:37 -0700, Phenex wrote:
> I will try to explain my quite special problem in in a few word,
> please excause my bad english...
> All i want is the modul-name of the view that calls the template
> renderer, wich of cause happen inside a view.
> The clou is, that these views can be in different modules (plugins),
> because this app is goin to be an pluggable framework on top of
> pyramid.
> To know wich template is to be loaded, the loader needs to know from
> what plugin the render function had been called. The template engine
> is jinja2, but that shoudn't matter, to do the magic a special loader
> has to be written (and this needs to know about this plugin).
> 
> The whole thing is a rewrite of an programm i did make in pylons. Back
> than i used request.environ['pylons.routes_dict']
> ['controller'].split(':', 1) to get the moduls name. I searched in in
> doku, an tried for hours but didn't find a way to get this
> information, hope anyone has an idea. I can access config an request,
> but didn't find anything usefull.

If you make all of your views into classes, you can use something like
this:

class MyView(object):
    def __init__(self, request):
        self.request = request

    @view_config(... your view configuration ....)
    def aview(self):
        module = self.__class__.__module__ # for example, 'myapp.views'

I wouldn't suggest trying to do this with views that are functions; it's
too painful.

- C


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to