On Mon, May 19, 2008 at 12:35 AM, Wichert Akkerman <[EMAIL PROTECTED]> wrote:
>
> Previously Aaron R wrote:
>> I did something similar using the __before__  method
>>
>> class CustomerController(BaseController):
>>      def __before__(self):
>>          if 'cust_id' in request.environ['pylons.routes_dict']:
>>               cust_id = request.environ['pylons.routes_dict']
>> ['cust_id']
>>               c.customer=meta.Session.query(Customer).get(cust_id)
>>          else:
>>               c.customer = None
>>
>>      def DoSomething(self, cust_id, id):
>>          .....
>>
>>      def DoMore(self, cust_id, id):
>>         .....
>>
>>
>> The routes_dict looks like this:
>>
>> {'action': u'dostuff', 'controller': u'customert', 'id': u'123'}
>>
>> Hopefully that works.
>
> It works and is indeed better. I still think my approach is nicer: it
> does not require poking manually at the routes memory but provides a
> clean interface.


def __before__(self, cust_id):


You can also use c.cust_id because all routing variables are shadowed onto 'c'.

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
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