On Thursday, April 7, 2011, Gael Pasgrimaud <[email protected]> wrote: > Hi, > > On Thu, Apr 7, 2011 at 4:47 PM, Eric Lemoine > <[email protected]> wrote: >> Hi >> >> I have view class defined as follows: >> >> class Entry(object): >> def __init__(self, request): >> self.request = request >> self.debug = "debug" in request.params >> lang = request.params.get("lang", >> request.registry.settings.get("default_locale_name")) >> self.lang = lang >> >> @view_config(route_name='home', renderer='templates/index.html') >> def home(self): >> return {'lang': self.lang, 'debug': self.debug} >> >> >> And a route to the "home" action defined with this: >> >> config.add_route('home', '/', view_attr='home') >> > > Don't know why you are using two different configuration. add_route > and view_config do the "same" thing. Eg: add an entry to the registry. > > You just need to use add_route: > > config.add_route('home', '/', view_attr='home', > view='yourmodule.Entry', renderer='...')
Hi Gael. I know this works, but I've been looking at separating concerns, that is specifying route-related stuff with add_route, and view-related stuff with view_config. As far as I know this can be achieved using route_name to bind the route to the view_config at config.scan time. But it doesn't work when specifying a view_attr in add_route. -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : [email protected] http://www.camptocamp.com -- 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.
