http://zerp.ly/rochacbruno
Em 13/11/2011 13:49, "Jonathan Lundell" <[email protected]> escreveu:
>
> On Nov 13, 2011, at 2:16 AM, Bruno Rocha wrote:
>
> > I just tested this:
> >
> > routes_in = (
> > ('/(?P<app>artigos|articulos|artiklid)', '/myapp/default/articles'),
> > )
> > routes_out = (
> > ('/myapp/default/articles', '/(?P<app>artigos|articulos|artiklid)'),
> > )
> >
> >
> > it works, but I can't receive args and vars, I am missing some wildcard
to match args/vars
> >
>
> Are you sure that routes_out works? It seems unlikely. Something like
this will get you args; vars will come along for free.
>
> routes_in = (
> (r'/(artigos|articulos|artiklid)\w(?P<args>.*)',
r'/myapp/default/articles\g<args>'),
> )
>
> routes_out is tougher; you really want an embedded function in the regex
replacement string, but I don't know whether Python regexes support that.
>
> Here's an alternative, though. I think it might work. In your controller,
do something like this:
>
> def articles():
> whatever
>
> artigos = articles
> articulos = articles
> artiklid = articles
>
it does not works. to work need to be
def artigos():
return aricles()
and repeat for others...
the only problem is that I cant rename the controller name in this way.
> ...and for outgoing URLs, just call URL() with the right string for the
current language.
>
>
> If that works, then generalize it with a better data structure. For
example:
>
> function_translate = {
> 'articles' : ('artigos', articulos', 'artiklid'),
> ...
> }
>
> ...where the translation tuple is in a known order (make yourself a set
of index constants to access it). Then write functions for making the
assignments in the controller, and for providing the translated string for
your URL() calls. You might even be able to do it with T(), but I think I'd
prefer to have this kind of thing more directly under my control.
>