Hi there,
The change of URL(...) from a string to an XML() helper bites me when
I upgrade my old web2py from trunk today.
I can change my own app's code to adapt the latest URL(...) behavior,
but am just writing to let people know there is one more scenario in
which the new URL(...) breaks code. Here is my favorite code.
response.menu = [
[ 'Home', request.url == URL(r=request, f='index'), URL(r=request,
f='index'), [] ],
[ 'About', request.url == URL(r=request, f='about'),
URL(r=request, f='about'), [] ],
....
]
The new URL(...) breaks above code because from now on,
URL(r=request) == URL(r=request)
would NEVER BE TRUE!
We have to write code like: str(URL(r=request)) ==
str(URL(r=request))
By the way, I strongly recommend Massimo to contain "link of the
discussion [1]" into hg commit log. That would make reader's life
easier.
[1]
http://groups.google.com/group/web2py/browse_frm/thread/a52007de9a7c5065/8327405064ccf9c3?lnk=gst&q=URL#8327405064ccf9c3
Regards,
Iceberg
On Aug 20, 9:38 am, mdipierro <[email protected]> wrote:
> There is a problem (in 1.83.2 and earlier version)
>
> URL(....)
>
> returns a string, not a helper. If you want to include the string
> without escaping twice you have to do
>
> {{=XML(URL(...))}}
>
> In trunk, I modified the definition ofURLso that it returns the
> XML(..) helper wrapping the string. This will prevent
>
> {{=URL(...)}}
>
> from double escaping but will prevent you from doing
>
> 'http://127.0.0.:8000'+URL(..)
>
> you would have to do
>
> 'http://127.0.0.:8000%s'%URL(..)
>
> we cannot have it both ways.
>
> URLis either a helper or a string... The more I think about it the
> more I am convincedURLshould be a helper not a string otherwise all
> the examples in which we use {{=URL(...)}} are buggy. Therefore this
> change should be considered a bug fix and not a breaking of backward
> compatibility.
>
> What do other people think? Should we change this as in trunk or leave
> it alone?
>
> Massimo
>
> On Aug 19, 1:39 pm, Phyo Arkar <[email protected]> wrote:
>
>
>
> > Trunk version Rev 853
>
> > in view:
> > $("#list").jqGrid({
>
> >url:"{{=URL(r=request,f='listMIME.json',vars={'extracted_path':extracted_pa
> >th,'source_path':source_path})}}",
>
> > HTML Result:
> > $("#list").jqGrid({
> > url:"/sExtract/extraction/listMIME.json?source_path=home*&*
> > ;extracted_path=target",
>
> > it insert &instead of &
>
> > that screwed up all my sites :D ..
>
> > have not tested with released version ..