>
> Right now the url to reach the index function of the country controller is
> something like www.myapp.com/country/cuba because index is set as the
> default function using the parametric router (
> www.myapp.com/country/index/cuba without set index() as default).
>
> Now I need to find a way to map
>
> www.myapp.com/country/index/cuba from www.myapp.com/cuba
> www.myapp.com/state/index/cuba/cienfuegos from
> www.myapp.com/cuba/cienfuegos
> www.myapp.com/city/index/cuba/cienfuegos/cienfuegos from
> www.myapp.com/cuba/cienfuegos/cienfuegos
>
I don't think you want to use URL rewrite rules to achieve this, as it will
be very complex to set up and maintain. Given the above requirements, I
think my earlier proposal makes much more sense -- just have a single
controller with a single function:
def index():
country, state, city = request.args(0), request.args(1), request.args(2)
if city:
data = get_city_data(country, state, city)
response.view = 'default/city_view.html'
elif state:
data = get_state_data(country, state)
response.view = 'default/state_view.html'
elif country:
data = get_country_data(country)
response.view = 'default/country_view.html'
...
Of course, the details of you implement the internal logic will depend on
exactly how different the code is for country vs. state vs. city.
Anthony
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.