What you need is the pattern-based routing system:
http://web2py.com/books/default/chapter/29/4#Pattern-based-system

The pattern-based system allows you to route URLs based on regular
expressions. You can convert certain portions of a URL into GET args
or vars.

web2py does not allow you to map URLs to arbitrary functions (i.e.,
you can't map /index to SomeObject().index() ), so instead you need to
map your desired URL to fit the way web2py routes URLs internally. So
if you created a function that would normally be accessed by

    /company/store/index

you can tell web2py to route

    GET /comapany/apple/store/567

to that function with the following entry in routes.py:

    routes_in = (
        ('/company/(?P<company>.*)/store/(?P<store>.*)', '/company/
store/index?company=\g<company>&store=\g<store>')
    )

This will route the request to the function associated with /company/
store/index, with "apple" in request.vars["company"] and "567" in
request.vars["store"].


On Dec 22, 1:00 pm, dum coder <[email protected]> wrote:
> Hello everyone, i'm new to Python and web2py , In Java Jersey REST
> framework i can map a REST URL to a function and get all the path
> parameters eg.,
>
> /comapany/{comapnyid}/store/{storeid}
>
> can be mapped to a particular function and companyid and storeid are
> accessible as
> parameters to function.
>
> i'm trying to find how can i accomplish similar functionality in
> web2py, where
>
> GET /comapany/apple/store/567
>
> gets mapped to a function and in side function i can retrieve
> companyid and storeid variables.
>
> I looked at function parse_as_rest but seems like it tried to run
> query against db, in  my
> case i just want to retrieve path parameters and then call other rest
> api  in other systems
>
> thanks

Reply via email to