Or you extract out shared logic to non-action methods or functions. Before encountering Pyramid we had already done this and gone down a very similar stylistic route to Pyramid's (our decorator is format- aware but I'm sure they're very similar). I'm not the world's greatest fan of decorators as they hide completely the decorated function/ method, but in something as idiomatic as a controller I think they can work well. Not excusing @validate though ;-)
Mike [email protected] http://positiveincline.com http://twitter.com/asplake On Feb 21, 4:35 pm, Jonathan Vanasco <[email protected]> wrote: > To be clear: > > This works: > > @action(renderer='/test_a.mako') > def test_a1(self): > return {'project':'myapp'} > > @action(renderer='/test_b.mako') > def test_b1(self): > return {'project':'myapp'} > > def test_c1(self): > return render_to_response('/test_b.mako', self.test_b1(), > request=self.request) > > But this doesnt: > > @action(renderer='/test_a.mako') > def test_a2(self): > return {'project':'myapp'} > > @action(renderer='/test_b.mako') > def test_b2(self): > return HTTPFound(location='/account/login') > > def test_c2(self): > return render_to_response('/account/test_b.mako', > self.test_b2(), request=self.request) > > Based on this pattern, I don't think it would be possible to migrate > any of my Pylons apps to Pyramid -- this behavior would require a > substantial rewrite of most controllers. > > 1- The way redirects / 404s are currently implemented creates a need > for additional logic in a dispatching function ( the results would > need to be tested, not handled by the framework ) > > 2- There looks to be a duplication in labor - a call to a dispatched > function would also require noting the template as well. So instead > of just noting the template at the function, you're also noting it at > anything that dispatches it. -- 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.
