Re: add_route and view_attr
On Thu, Apr 7, 2011 at 8:20 PM, Michael Merickel mich...@merickel.org wrote: To solve your problem you probably just need to remove the view_attr from add_route and call config.scan(). The problem here is the ambiguity in add_route because it supports routes and the ability to add a single view. Rather add_view and view_config are identical except that view_config requires to you call config.scan() to place the decorator within your code, instead of within your config. You're right. It makes sense. And it works! Thank you. -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : eric.lemo...@camptocamp.com 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 pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
add_route and view_attr
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') But Pyramid complains: pyramid.exceptions.ConfigurationError: view_attr argument not permitted without view argument The thing is I'd like to specify the renderer through the view_config decorator, so it is defined as close as possible to my home def. But using add_route, and binding view_config and add_route together through the route_name attribute, doesn't work either. Is there a solution to this problem? Thanks, -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : eric.lemo...@camptocamp.com 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 pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: add_route and view_attr
On Thursday, April 7, 2011, Gael Pasgrimaud g...@gawel.org wrote: Hi, On Thu, Apr 7, 2011 at 4:47 PM, Eric Lemoine eric.lemo...@camptocamp.com 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 : eric.lemo...@camptocamp.com 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 pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Re: add_route and view_attr
To solve your problem you probably just need to remove the view_attr from add_route and call config.scan(). The problem here is the ambiguity in add_route because it supports routes and the ability to add a single view. Rather add_view and view_config are identical except that view_config requires to you call config.scan() to place the decorator within your code, instead of within your config. Michael On Thu, Apr 7, 2011 at 11:30 AM, Eric Lemoine eric.lemo...@camptocamp.comwrote: On Thursday, April 7, 2011, Gael Pasgrimaud g...@gawel.org wrote: Hi, On Thu, Apr 7, 2011 at 4:47 PM, Eric Lemoine eric.lemo...@camptocamp.com 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 : eric.lemo...@camptocamp.com 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 pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.