On 7 Aug 2012, at 7:17 AM, Daniel Gonzalez <[email protected]> wrote:
> Thanks Jonathan, Bruno,
> 
> I am a bit confused: where is this routes.py file? Is it a web2py-wide file, 
> or an application-specific file?

It goes in the web2py root directory. There's a pair of example files for the 
two different router styles that are intended to be copied to routes.py and 
used as the basis for your own routing.

In addition, both routers (pattern and parametric) allow an *additional* 
routes.py in each application root directory. This is perhaps more useful in 
the pattern-based router than the parametric router, and in any case the root 
router is required to make (at a minimum) the determination of which app is 
being addressed.

One more thing to keep in mind: web2py loads the routes.py file(s) at startup, 
or when explicitly asked to (eg by the admin app). So route changes won't be 
reflected until the new routes are reloaded, one way or another. This can be a 
cause for confusion when you're developing your routes, so keep it in mind.

> 
> Thanks,
> Daniel
> 
> On Thursday, August 2, 2012 9:47:24 PM UTC+2, Jonathan Lundell wrote:
> On 2 Aug 2012, at 12:34 PM, Bruno Rocha <[email protected]> wrote: 
> > routes.py 
> > ################################################ 
> > routers = dict( 
> >     BASE = dict( 
> >         default_application = 'myapp', 
> >         default_controller = 'mycontroller', 
> >         default_function = 'function1', 
> >         controllers = ['default', 'mycontroller', 'etc'], 
> >         functions = ['function1', 'function2', 'function3'], 
> >         applications = ["myapp", "admin"] 
> >        ) 
> > ) 
> > 
> > ############################################### 
> > 
> > The hardest part is that you have to list each controller, app, function 
> 
> Not really. By default, the router will pick up all the apps and controllers; 
> you just need to list functions if you want to be able to do certain more 
> aggressive shortening. 
> 
> BTW, put app-specific parameters in the app's router dict, not in BASE. 
> 
> routers = dict( 
>     BASE = dict( 
>         default_application = 'myapp', 
>        ), 
>     myapp = dict( 
>         default_controller = 'mycontroller', 
>         default_function = 'function1', 
>         functions = ['function1', 'function2', 'function3'], 
>     ), 
> ) 
> 
> 
> >     
> >         
> > 
> > On Thu, Aug 2, 2012 at 4:13 PM, Daniel Gonzalez <[email protected]> wrote: 
> > Hi, 
> > 
> > I am running web2py with mod_wsgi behind apache. I have a single web2py 
> > application. 
> > I would like to do the following URL mapping: 
> > 
> > http://www.example.com/function1 -> myapp/mycontroller/function1 
> > 
> > Where myapp is my application, which is only one. 
> > I do not have lots of functions, so maybe I can create a single controller 
> > file, mycontroller.py 
> > And then I will define all functions that I need in that controller: 
> > function1, function2, ... 
> > 
> > How would I go about implementing this? Is this something that is better 
> > done at the apache level, or at the web2py level? 
> > What are the thoughts / strategies used by people more familiar with 
> > web2py? 
> > 
> > Thanks and regards, 
> > 
> 
> 
> 
> -- 
>  
>  
>  


-- 



Reply via email to