You can write your own view_config decorator that does not use view_config. The reason you would want to do this is that in your own decorators, when venusian scans, it will send you the config object. Thus you can (in the venusian callback) grab the config object, look at config.registry.settings and determine whether you want to call config.add_view then or not. The best way to do this is copy the view_config code verbatim out of pyramid and modify it with your checks.
On Tue, Dec 18, 2012 at 3:47 PM, Mike Orr <[email protected]> wrote: > Sometimes I want to register a view or suite of views conditionally; > e.g., to add development views only if a 'debug' setting is true. It > looks like this is impossible with '@view_config': there's no way to > disable it if the setting is false. This is causing me to to register > conditional views with config.add_view() in an include function, which > then means I'm registering some views one way and some another way, > which is messy. > > The only way around this I can think of is to exclude the module from > the general scan, and to only scan it if the setting is true. But that > means I have to put the module outside the views/ package, which is > also messy. > > Is there another way to do this? > > -- > 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. > > -- 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.
