Well,
After some tries, I have found a solution :
In web2py folder :
*routes.py*
# -*- coding: utf-8 -*-
routes_app = ((r'/(?P<app>admin)\b.*', r'\g<app>'),
(r'(.*)', r'myApp'),
(r'/?(.*)', r'myApp'))
In my app folder :
*routes.py*
# -*- coding: utf-8 -*-
routes_in = (
('/myApp/!$a', '/myApp/pages/show_page/$a'),
('/myApp', '/myApp/default/index'),
('/myApp/images', '/myApp/images/images'),
('/myApp/contact', '/myApp/default/contact_form'),
)
routes_out = [(x, y) for (y, x) in routes_in]
Everything works fine excepted one thing :
an incoming url like *http://www.myapp.com/pages/show_page/foo* is rewrited
in *http://www.myapp.com/foo *==> that's OK
an incoming url like *http://www.myapp.com/pages/show_page/foo-bar* is not
rewrited*
*
it seems that *hyphens *in the last parameter prevents rewriting
Any idea why?
thank you
*
*
Le vendredi 3 mai 2013 08:42:03 UTC+2, Loïc a écrit :
>
> yes default_app is just to allow access to my app at
> http://127.0.0.1:8000(without specifying an app name)
>
> "*You probably still need to specify "myApp" in your routes.*"
>
> In my app-specific routes;py tried
> #!/usr/bin/python
> # -*- coding: utf-8 -*-
> routes_in = (
> ('/myApp/testme', '/myApp/default/index'),
> )
> routes_out = (
> ('/myApp/default/index', '/myApp/testme'),
> )
>
> But when I go on http://127.0.0.1:8000/myApp/testme
> I still have an error :
> invalid controller (testme/index)
>
> I'm testing on Windows7 pro x64 with default rocket webserver. Could it
> cause some issues?
> Thank you
>
> Le jeudi 2 mai 2013 16:57:00 UTC+2, Anthony a écrit :
>>
>> I think default_app just tells it where to go if there is no app,
>> controller, or function. You probably still need to specify "myApp" in your
>> routes.
>>
>> Anthony
>>
>> On Thursday, May 2, 2013 9:54:20 AM UTC-4, Loïc wrote:
>>>
>>> Thank you anthony for your quick response.
>>>
>>> I updated *web2py\routes.py* to remain only the following line :
>>>
>>> # -*- coding: utf-8 -*-
>>> default_application = "myApp"
>>>
>>> When I open http://127.0.0.1:8000 I am redirected to myApp. So This
>>> routes.py file seems to be OK
>>>
>>> Then, on *web2py\applications\myApp\routes.py* I wrote :
>>> routes_in = (
>>> ('/testme', '/myApp/default/index'),
>>> )
>>> routes_out = (
>>> ('/myApp/default/index', '/testme'),
>>> )
>>>
>>> But when I go to http://127.0.0.1:8000/myApp/testme I still have an
>>> error
>>> invalid controller (testme/index)
>>>
>>>
>>> I have also tested with *web2py\applications\myApp\routes.py* :
>>>
>>> #!/usr/bin/python
>>> # -*- coding: utf-8 -*-
>>>
>>> routes_in = (
>>> ('/testme', '/default/index'),
>>> )
>>> routes_out = (
>>> ('/default/index', '/testme'),
>>> )
>>>
>>> But I have the same error :
>>> invalid controller (testme/index)
>>> Le jeudi 2 mai 2013 15:27:50 UTC+2, Anthony a écrit :
>>>>
>>>> You cannot combine the parameter-based and pattern-based rewrite
>>>> systems -- pick one or the other.
>>>>
>>>> On Thursday, May 2, 2013 8:29:37 AM UTC-4, Loïc wrote:
>>>>>
>>>>> Hello all,
>>>>>
>>>>> I want to play with URL revrite. So I took the example in the book (
>>>>> http://web2py.com/books/default/chapter/29/04?search=routes_in#Pattern-based-system
>>>>> )
>>>>>
>>>>> In the file *web2py\applications\myApp\routes.py* I have :
>>>>> #!/usr/bin/python
>>>>> # -*- coding: utf-8 -*-
>>>>>
>>>>> routes_in = (
>>>>> ('/testme', '/myApp/default/index'),
>>>>> )
>>>>> routes_out = (
>>>>> ('/myApp/default/index', '/testme'),
>>>>> )
>>>>>
>>>>> In web2py root dir, I also added a routes.py file containing :
>>>>> # -*- coding: utf-8 -*-
>>>>>
>>>>> routers = dict(
>>>>> BASE=dict(
>>>>> default_application='myApp',
>>>>> ),
>>>>> )
>>>>>
>>>>>
>>>>> I restarted web2py to reload routes, but when I go on
>>>>> http://127.0.0.1:8000/testme or on http://127.0.0.1:8000/myApp/testmeI
>>>>> have an error :
>>>>> invalid function (default/testme)
>>>>>
>>>>>
>>>>> Can somebody explain me what is wrong is my routes.py files?
>>>>>
>>>>> Thank you
>>>>>
>>>>>
--
---
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/groups/opt_out.