Gregory W. Bond wrote: > i've been scratching my head about how to do this with Routes but i'm > beginning to think it's not possible > > what i want to do is compute the controller value based on (dynamic > parts) of the requested url - for example, if the requested url is / > users/[user]/account/[account], i'd like to be able to provide Routes > with a function to compute the controller value based on the values of > 'user' and 'account' > > nothing i've seen in this group or in the Routes documentation says > this isn't possible - on the other hand, i haven't been able to find > any examples of how this might be accomplished either >
Routes does not provide a way to do what you want because, internally, it uses regular expressions to determine the controller and your desired feature is too dynamic to be expressed as an RE. > assuming that Routes doesn't support this, the only other approach i > think might work is to use the paste.recursive module as described in > this post: > http://groups.google.com/group/pylons-discuss/browse_frm/thread/2dcc9af2e051330a/33a7e67ec195548a?lnk=gst&q=redirect&rnum=2#33a7e67ec195548a > > using this approach, the idea would be to have Routes direct the > request to a default controller and then the default controller would > self-redirect to the computed controller > > however the post specifies that to make this work the redirecting > controller cannot inherit from pylons.Controller - what i don't > understand is what the redirecting controller should look like if it > can't inherit from pylons.Controller - can anybody provide a simple > example? That is a pretty old thread; I don't know why James said I'm pretty sure you can use the recursive middleware without problems. The request should go all the way through the stack again. Also, you might find it easier to just use a normal python call into the other controller to handle the request, instead of using recursive middleware. Cheers, David --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
