What you're looking for is a 'view mapper'. You should be able to find information about view mappers in the Pyramid docs.
On June 25, 2014 5:03:46 AM EDT, Achim Domma <[email protected]> wrote: >Hi, > >I would like to modify the way, how my views are called. The idea would >be, >to "inject" some code, which maps the request and context objects to a >set >of different arguments, which are then passed to the view. To make it >more >concrete: > >At the moment I do something like this: > >def my_view(context, request): > some_data = request.get_some_data() > other_data = request.get_other_data() > > # no dependency on request below this line > # .... > >As I have a similar structure in most of my views, I would like to >implement a functions like this: > >def map_args(context, request): > # .... > return (some_data, other_data, even_more_data) > >That function should be put in front of my view and the view could now >be >written as: > >def my_view(some_data, other_data, even_more_data): > # ... > >Based on the modularity of Pyramid, I think this should be possible, >but I >did not found the right hook / entry point. Any hint would be very >appreciated. > >I'm aware that I might be able to solve this in some view base classes >or >using decorators, but we use plain view functions and view classes and >would have to support all this cases. So modifying Pyramids calling >strategy looks much cleaner to me. > >cheers, >Achim > >-- >You received this message because you are subscribed to the Google >Groups "pylons-discuss" 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/pylons-discuss. >For more options, visit https://groups.google.com/d/optout. -- Sent from my Android device with K-9 Mail. Please excuse my brevity. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
