Hi howsec.

Thank you for your help again.
Now I did the following: I figured out that I could use map_hyphens as True
and create the functions inside the default controller to treat the urls
with hyphens that would be redirected!
I did the following inside default.py... and things are working now,
withtout using regex based router!



def jogos_e_games():
    return _trataRedirecionamentos()

def carro_conceito():
    return _trataRedirecionamentos()

def novo_modelo():
    return _trataRedirecionamentos()






On Fri, Nov 2, 2012 at 8:07 PM, howesc <how...@umich.edu> wrote:

> i use the regex based router....so i'm not up on all the options for the
> parametric router.
>
> that said, 2 things come to mind:
>  - invalid controller might return a 500?  you could try that in your
> routes.on_error (try catching 500 errors i mean).
>  - for web2py to be happy you'd need to rewrite the URL to not have
> hyphens in what gets mapped to the controller or function name (as that
> breaks python).  remember that in web2py URLs are
> application/controller/function.  to not raise an error your router will
> need to attach an application, controller, and function to each of your
> URLs with hyphens before they will parse without error.
>
> i hope that helps point you in the right direction....
>
> cfh
>
>
> On Friday, November 2, 2012 4:18:44 AM UTC-7, Alex Benfica wrote:
>>
>> Hi people!
>>
>> I'm creating a new website using Web2py [ Version 2.0.0 (2012-06-10
>> 21:17:42) dev ] on GAE in a domain where previously I had a WordPress blog!
>>
>> This blog has some urls like these:
>>
>> http://domain.com/novo-modelo/**hyundai-hb-20/<http://domain.com/novo-modelo/hyundai-hb-20/>
>> http://domain.com/carro-**conceito/nanotata/testes/<http://domain.com/carro-conceito/nanotata/testes/>
>>
>> In order to not lose the whole traffic to the old blog, it were
>> transfered to another domain and I need to make http 301 redirects to all
>> of his pages!
>>
>> I'm using the following approach:
>>
>> I catch the 404 erros and verify if the request_uri is one of the urls
>> from the old blogs I need to redirect ( I have all urls taken from the
>> sitemap.xml ).
>> This works fine, except for urls like those before, that have hyphens in
>> the first "arg" as in "novo-modelo" and "carro-conceito".
>>
>>
>>
>> I did that on routes.py:
>>
>> routes_onerror = [
>>     (r'*/404', r'/init/httpcodes/cod404')
>> ]
>>
>>
>> And in the function cod404, I verify the URL and do the redirect if the
>> URL is from the old blog!
>>
>>
>> When the URL is
>>
>> http://domain.com/novo-modelo/**hyundai-hb-20/<http://domain.com/novo-modelo/hyundai-hb-20/>
>>
>> I got the error: "invalid request"... and it is not treated as 404!
>>
>> What can I do to allow web2py understand this URL as 404?
>>
>>
>> I tryed map_hyphen = True but had no success!
>>
>> This are the some other informations on my router.py.
>>
>>
>>
>> default_router = dict(
>>     default_application = 'init',
>>         applications = 'ALL',
>>     default_controller = 'default',
>>         controllers = 'DEFAULT',
>>     default_function = 'index',
>>         functions = None,
>>     default_language = None,
>>         languages = None,
>>     root_static = ['favicon.ico', 'robots.txt'],
>>     domains = None,
>>     map_hyphen = False,
>>     acfe_match = r'\w+$',              # legal app/ctlr/fcn/ext
>>     file_match = r'(\w+[-=./]?)+$',    # legal file (path) name
>>     args_match = r'([\w@ -]+[=.]?)+$', # legal arg in args
>> )
>>
>>
>>
>>
>>
>>
>> #  This simple router set overrides only the default application name,
>> #  but provides full rewrite functionality.
>>
>> routers = dict(
>>
>>     # base router
>>     BASE = dict(
>>         default_application = 'init',
>>     ),
>> )
>>
>>
>>  --
>
>
>
>



-- 
--

Atenciosamente,
Alex BENFICA

--
"O que não se mede não se gerencia."

-- 



Reply via email to