On Jun 4, 1:05 pm, Ben Bangert <[email protected]> wrote:
> On Jun 4, 2009, at 6:14 AM, ilmarik wrote:
>
> > Is there any chance to use links like:
> >http://domain.com?c=controller&a=action&param1=&param2=
>
> > and router maps controller and action automaticaly?
>
> If you really wanted to, sure, you could put those in the query args.  
> You'll want to look at using a conditional function, and modifying the  
> match dict. For example, here's a conditional route function that  
> changes the action:http://pylonshq.com/pasties/914
>
> You could of course pull out the controller/action from the query, and  
> set those as well, then you'd define it with:
> map.connect('/', conditions=dict(function=my_fixup_function))

FWIW, a similar idea, but using only "canonical" route setup:

In routing.py, the usual:

    def make_map():
        # ...
        map.connect('/{controller}/{action}')
        # ...

...and this, too:

    RoutesPreProcessorMiddleware(object):
        def __init__(self, app):
            self.app = app
        def __call__(self, environ, start_response):
            # ...look in `environ` and adjust PATH_INFO and
QUERY_STRING to match routing setup...
            return self.app(environ, start_response)

In middleware.py:

    # ...
    app = RoutesMiddleware(app, config['routes.map'])
    app = RoutesPreProcessorMiddleware(app)
    # ...

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to