On Tue, Mar 16, 2010 at 6:58 AM, Andrew <[email protected]> wrote: > Hello, > > I'm trying to setup versioned routes, i.e. for application named "app" > with multiple actions act1, act2, etc., I would like the following: > > /app/0.1/act1 > > And would then resolve the URL to be something like: > > /{controller}/{action} > { 'controller' : 'app/0.1', 'action' : 'act1' } > > Is there anyway to set this up so that the controller will match both > "app" and the "version"? I've tried using regular expressions, ala > {controller:app/\d\.\d}, but Routes seems to treat the controller as a > special variable and ignores it; this does not happen with non- > reserved values. Right now, the only option I can get to work is to > redirect /app/0.1 to /app-0.1 and have an appropriately named > controller, but this seems a little clunky to me. > > Since this will potentially have many versions, I don't want this > being passed in as a variable and being interpreted within a > controller or action. > > Does anybody have any suggestions on how this might work?
'controller' is handled specially in two ways. One, there's a controller scan argument that makes the mapper list the valid controller names at instantiation and allow only those. Or you can pass in a static list of controller names. Also, controller defaults to 'content' if map.explicit == False (now deprecated). But more to the point, I don't see how you can have a controller 'app/1.0' because "1.0" because Pylons uses the 'controller' variable to look up a module and class to instantiate, and "1.0" is not a valid Python module name. The most straightforward way for versioning I can think of is to move the version earlier in the URL as a separate variable. /app/0.1/mycontroller/action . In this case, you'd need a stub action (unversioned) that delegates to the versioned action. -- 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.
