I personally always use routes... for me, it's just a matter of my perspective. As a developer I am thinking from the conrollers perspective. I want to call a particular function in a controller . No doubt in my programming mind, I should always want to call things from the controller with a python command. :P But that's just my take. BR, J
On Thu, 2010-10-21 at 08:03 -0700, mdipierro wrote: > I think it is very important to use URL and not hard-code any url. > > If you deploy the app under apache for example, in a subfolder, you > need to add the /subfoldername/ prefix to all paths. It will break all > urls. URL and routes will take care of this. > > On Oct 21, 9:38 am, Jonathan Lundell <[email protected]> wrote: > > On Oct 20, 2010, at 11:18 PM, ron_m wrote: > > > > > > > > > Certainly the way you describe is in the book and is right, what I > > > suggest is something I have done that works. However it could be one > > > of things that bites later because I am depending on the current > > > mapping of args to additional path elements and am essentially > > > bypassing what the API should be doing for me. I need to reconsider > > > how I am doing this part of my menus - still learning this framework. > > > Being a former Java head and for a while PHP it sure is nice to work > > > with both Python and web2py. > > > > > Thanks for the pointer. > > > > It's largely a matter of style. The only compelling reason to use URL() at > > all is if you're rewriting your URLs via routes.py. In that case, URL does > > the outgoing rewrites. Otherwise, it's just a helper, and the only reason > > to use the flavor I suggested is for readability. If you're not doing > > rewrites, you could just as well say: > > > > '/appname/default/products/used' > > > > or > > > > '/%s/default/products/used' % request.application > > > > if you don't want to embed the appname into the code. > > > > But you (or someone else) might want to add rewriting later on, for some > > reason or other (maybe mapping domains to applications), so I'm *not* > > advocating that anyone actually do that. > > > > > > > > > Ron > > > > > On Oct 20, 10:55 pm, Jonathan Lundell <[email protected]> wrote: > > >> On Oct 20, 2010, at 10:44 PM, ron_m wrote: > > > > >>> This works > > > > >>> URL(request.application,'default','products/used'), []) > > > > >> You can also do something like this, which to my mind is more readable: > > > > >> URL('default', 'products', args=['used']) > > > > >> or equivalently, and even more readable: > > > > >> URL(c='default', f='products', args=['used']) > > > > >> I say "something like" because I didn't explicitly test it. > > > > >>> On Oct 20, 7:40 pm, Jason Brower <[email protected]> wrote: > > >>>> response.menu = [ > > >>>> (T('Home'), False, URL(request.application,'default','index'), []), > > >>>> (T('Products'), False, > > >>>> URL(request.application,'default','products'), []), > > >>>> (T('Used Products'), False, > > >>>> URL(request.application,'default','products'), []), > > >>>> (T('Company'), False, URL(request.application,'default','company'), > > >>>> []) > > >>>> ] > > >>>> Notice I have to products pages... basically they are they same but > > >>>> they > > >>>> have some feilds I want different in them... one will go to > > >>>> default/products and the other to default/products/used. > > >>>> BR, > > >>>> Jason > > > > >>>> On Wed, 2010-10-20 at 11:26 -0700, mdipierro wrote: > > >>>>> ? > > > > >>>>> On Oct 20, 12:26 pm, Jason Brower <[email protected]> wrote: > > >>>>>> Are there no arg in response.menu? If not I can build it different, > > >>>>>> but > > >>>>>> I thought it would so I can do some special menu items. > > >>>>>> :/ Innerestin' > > >>>>>> --- > > >>>>>> BR, > > >>>>>> Jason > > > > >>>>>> face-uncertain.png > > >>>>>> 1KViewDownload > > > >
<<attachment: face-raspberry.png>>

