I have a lot of code wrote in this sintax, But, ig its wrong, no problem to replace.
Will this still works? _href=URL(request.application,'plugin_wiki','page',args=[row,]) Sent from my iPhone On 30/07/2010, at 04:05, mdipierro <[email protected]> wrote: > You are right but it only breaks backward compatibility in a case > where things would be misleading. Here are some example: > > # old syntax that still works > URL('a','c','f') > URL(a='a',c='c',f='f') > URL(f='f',r=request) > > #new syntax that resulted in an error before > URL('f') > URL('c','f') > URL(f='f') > URL(c='c',f='f') > > ## changed of behaviour > URL('a',r=request) > was /a/current_controller/current_function > now > was /current_app/current_controller/a > > I.e. the change of behavior only occurs if the user explicitly > specifies r and a (without naming a) but not f. I.e. if the user is > specifying redundant information that may be conflicting (because a > may differ from r.application). Users should not be doing this anyway. > I have never seen anybody doing this. > > Did I miss something? can you see any other case when the behavior > would change? > > What do other people think? > > Massimo > > > > > > > > > > > > > On Jul 29, 8:27 pm, Thadeus Burgess <[email protected]> wrote: >> Massimo, you cannot >> >> I am sorry but that would break backwards compatibility. >> >> Say if in certain apps you have this (in alot of the earlier apps on >> web2py.com do this too) >> >> URL(request.application, 'static', 'logo.png') >> >> Or >> >> URL(request.application, 'default', 'index') >> >> Unfortunately, we cannot re-arrange the variables defined in URL from this >> order >> >> def URL( >> a=None, >> c=None, >> f=None, >> r=None, >> args=[], >> vars={}, >> anchor='', >> extension=None, >> env=None >> ): >> >> -- >> Thadeus >> >> On Thu, Jul 29, 2010 at 8:23 PM, Michele Comitini >> >> <[email protected]> wrote: >>> thumbs up! >> >>> 2010/7/30 mdipierro <[email protected]> >> >>>> I took it one step further... >> >>>>>>> URL() >>>> /app/default/index >>>>>>> URL('test') >>>> /app/default/test >>>>>>> def test(): return 'test' >>>>>>> URL(test) >>>> /app/default/test >>>>>>> URL('static','filename') >>>> /app/static/filename >>>>>>> URL('other','static','filename') >>>> /other/static/filename >> >>>> No more r=, c=, f= needed but all optional. >> >>>> On Jul 28, 6:28 pm, Thadeus Burgess <[email protected]> wrote: >>>>> SORRY! =D >> >>>>> -- >>>>> Thadeus >> >>>>> On Wed, Jul 28, 2010 at 6:22 PM, mdipierro <[email protected]> >>>>> wrote: >>>>>> WOW. Uploading to trunk. Now I need to revise the book again. :-( >> >>>>>> On Jul 28, 5:51 pm, Thadeus Burgess <[email protected]> wrote: >>>>>>>>>> URL(r=request, c='hello', f='world', args=['hi'], >>>>>>>>>> vars={'q':'greetings'}, anchor='the_world') >> >>>>>>> '/welcome/hello/world/hi#the_world?q=greetings'>>> URL(c='hello', >>>>>>> f='world', args=['hi'], vars={'q':'greetings'}, anchor='the_world') >> >>>>>>> '/welcome/hello/world/hi#the_world?q=greetings' >> >>>>>>> Attached is the diff >> >>>>>>> This should not effect any current usages of URL, but from this point >>>>>>> forward we shouldn't have to specify r=request! >> >>>>>>> -- >>>>>>> Thadeus >> >>>>>>> On Wed, Jul 28, 2010 at 5:21 PM, mdipierro <[email protected]> >>>>>>> wrote: >>>>>>>> ok >> >>>>>>>> On Jul 28, 4:52 pm, Thadeus Burgess <[email protected]> wrote: >>>>>>>>> For a little more advanced version of what Massimo just posted: >> >>>>>>>>> This allows you to use both. >> >>>>>>>>> URL(r=request, c=<controller>, f=.....) >>>>>>>>> and >>>>>>>>> URL(c=<controller>, f=<function>.....) >> >>>>>>>>>>> http://packages.python.org/web2py_utils/init.html#gurlhttp://hg.thade...... >> >>>>>>>>> The reason we have to pass the request to URL each time is because >>>>>>>>> it >>>>>>>>> is just imported into the context. Since it is just a python >>>>>>>>> function, >>>>>>>>> it has no knowledge of request. >> >>>>>>>>> Why can't we do something like gURL from within web2py? When >>>>>>>>> building >>>>>>>>> the context, why can't we make URL a loaded function that will get >>>>>>>>> request passed to it, exactly how gURL works. >> >>>>>>>>> Effectively, we won't have to pass request into URL function >>>>>>>>> anymore... ever. >> >>>>>>>>> If your interested, I can work on the patch. >> >>>>>>>>> -- >>>>>>>>> Thadeus >> >>>>>>>>> On Wed, Jul 28, 2010 at 3:56 PM, mdipierro >>>>>>>>> <[email protected]> wrote: >>>>>>>>>> 1) It is a bit more complex because of static, appadmin, and >>>>>>>>>> admin. >>>>>>>>>> You can map >> >>>>>>>>>> /function/var1/var2 >> >>>>>>>>>> into >> >>>>>>>>>> /app/controller/function/var1/var2 >> >>>>>>>>>> using a file routes.py >>>>>>>>>> ------- begin file >>>>>>>>>> routes_in=[ >>>>>>>>>> ('/admin/$anything','/admin/$anything'), >>>>>>>>>> ('/static/$anything','/app/static/$anything'), >>>>>>>>>> ('/appadmin/$anything','/app/appadmin/$anything'), >>>>>>>>>> ('/$anything','/app/default/$anything'), >>>>>>>>>> ] >>>>>>>>>> routes_out=[(y,x) for (x,y) in routes_in] >>>>>>>>>> ----- end file >> >>>>>>>>>> 2) in db.py define >> >>>>>>>>>> def url(f,args={},vars={}): >>>>>>>>>> return URL(r=request,f=f,args=args,vars=vars) >>>>>>>>>> def go(f,args={},vars={},flash=''): >>>>>>>>>> session.flash=flash >>>>>>>>>> return go(url(f=f,args=args,vars=vars)) >> >>>>>>>>>> and use >> >>>>>>>>>> url('index') >> >>>>>>>>>> or >> >>>>>>>>>> go('index',flash='you are being redirected') >> >>>>>>>>>> I do it all the time >> >>>>>>>>>> On Jul 28, 3:29 pm, VP <[email protected]> wrote: >>>>>>>>>>> I'm a newbie, so my questions probably have easy answers, but >>>>>>>>>>> anyway. >>>>>>>>>>> Among a few things, there are two I don't understand and think >>>>>>>>>>> can be >>>>>>>>>>> simplified. >> >>>>>>>>>>> 1. this url: app/controller/function/var1/var2 >> >>>>>>>>>>> For me at least, most of the time I probably have only one >>>>>>>>>>> controller. If there is one controller, may be we should get >>>>>>>>>>> rid of >>>>>>>>>>> "controller" in the url? This will be sufficient: >>>>>>>>>>> app/f/a/b/c >> >>>>>>>>>>> 2. Similarly, most of the time I have only one app (current >>>>>>>>>>> app). >>>>>>>>>>> But I use URL() a lot and every time I have to pass in request >>>>>>>>>>> like >>>>>>>>>>> this URL(r=request, f='foo'). >> >>>>>>>>>>> Why do I have to pass in request if I have only one app, one >>>>>>>>>>> controller? >> >>>>>>>>>>> Furthermore, isn't request supposed to be global? If so, do we >>>>>>>>>>> have >>>>>>>>>>> to pass it in? >> >>>>>>> url_proxy.diff >>>>>>> 1KViewDownload

