I mean
page_name /controller/action/arg1/arg2?a='Hello Computer'&b=5
page_name /controller/action/arg1/arg2?a=Hello+Computer&b=5
Should be equivalent. So the code should:
0) If path starts with /
1) use regex to find "'(?P<x>.*(?<!\\\\))'" and replace with
urllib.quote(math.group('x'))
2) break the URL into controller, action, everything-else
3) rebuild the url using URL(..) (in case routes is being used)
Not too easy but should do it.
On Jan 4, 3:33 pm, blackthorne <[email protected]> wrote:
> sure, I'm just not sure what you mean with optional quotes.
>
> e.g.:
> page_name /controller/action/arg1/arg2?a='Welcome page2'
> /Computers /controller/action/arg1/arg2?a=Hello Computer
>
> should become:
> page_name -> /controller/action/arg1/arg2?a='Welcome page2'
> /Computers -> /controller/action/arg1/arg2?a='Hello Computer'
>
> like this?
>
> On Jan 4, 5:47 pm, mdipierro <[email protected]> wrote:
>
> > I think we can go this way:
>
> > page_name /controller/action/arg1/arg2?a='Welcome page2'
>
> > but I would make so that the quotes optional (if provided content will
> > be replaced by urllib.quote(content).
>
> > Would you send me a revised patch?
>
> > On Jan 4, 11:21 am, blackthorne <[email protected]> wrote:
>
> > > Well, I see your view.
>
> > > In some cases, you can just use %20 instead of white space but not if
> > > that is part of the argument.
> > > example:http://prernalal.com/banned%20books/==http://prernalal.com/banned
> > > books/ - validhttp://example.com/?page="banned%20books"
> > > !=http://example.com/?page="banned
> > > books" - not valid
>
> > > I think this character separation (white space) for meta-menu is way
> > > too common. It's likely that the limitations won't stick with my
> > > examples. An option to define it manually would solve it for all
> > > cases, even if not by convention.
>
> > > Aanother idea would be using newlines. One for different parts, two
> > > for different options, e.g:
> > > page_name
> > > /controller/action/arg1/arg2?a='Welcome page'
>
> > > page_name2
> > > page_name /controller/action/arg1/arg2?a='Welcome page2'
>
> > > This way it's clean, almost fail-proof and leaves you room to add
> > > things with an arbitrary number of arguments/parts.
>
> > > On the other hand, your latest suggestion doesn't require any change,
> > > which is a plus.
>
> > > On Jan 4, 4:59 pm, mdipierro <[email protected]> wrote:
>
> > > > This is a big can of worms... Do we really need to pass vars?
>
> > > > On Jan 4, 10:45 am, blackthorne <[email protected]> wrote:
>
> > > > > sorry, I was considering on using the same code to the wiki pages in
> > > > > the markmin syntax so that you could also make this kind of links in
> > > > > wiki pages.
> > > > > [[namehttp://example.com, args=[], vars={}]]
>
> > > > > Other thing, you might want to consider...
> > > > > check your example
> > > > > page_name /controller/action/arg1/arg2?a=b
>
> > > > > instead of b if you have a string such as 'welcome page', it won't
> > > > > work because of the white space.
> > > > > page_name /controller/action/arg1/arg2?a='Welcome page'
>
> > > > > idea:
> > > > > changing the meta-menu separator character to '|' or '||'
>
> > > > > example:
> > > > > page_name|/controller/action/arg1/arg2?a='Welcome page'
>
> > > > > On Jan 4, 4:33 pm, mdipierro <[email protected]> wrote:
>
> > > > > > Are we still talking about menu links? Why should a menu item
> > > > > > perform
> > > > > > a post?
>
> > > > > > On Jan 4, 10:31 am, blackthorne <[email protected]> wrote:
>
> > > > > > > fine with me
>
> > > > > > > any solution for POST method?
>
> > > > > > > On Jan 4, 4:25 pm, mdipierro <[email protected]> wrote:
>
> > > > > > > > I have no objection to local URL. but the author of the menu
> > > > > > > > may not
> > > > > > > > be the administrator therefore we cannot eval(...) text in the
> > > > > > > > meta-
> > > > > > > > menu. This poses restrictions on what we can put in there. I
> > > > > > > > suggest
> > > > > > > > we just allow
>
> > > > > > > > page_name /controller/action/arg1/arg2?a=b
>
> > > > > > > > and if this starts with / this is interpreted as a local URL.
> > > > > > > > No need
> > > > > > > > to specify app name.
>
> > > > > > > > On Jan 4, 10:09 am, blackthorne <[email protected]> wrote:
>
> > > > > > > > > no local urls for secure mode... yes/no?
>
> > > > > > > > > On Jan 4, 3:51 pm, mdipierro <[email protected]> wrote:
>
> > > > > > > > > > There cannot be eval in there. The plugin may be in level=1
> > > > > > > > > > (secure
> > > > > > > > > > mode).
>
> > > > > > > > > > On Jan 4, 8:38 am, blackthorne <[email protected]>
> > > > > > > > > > wrote:
>
> > > > > > > > > > > Broken here:
> > > > > > > > > > > In [21]: url="\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')"
>
> > > > > > > > > > > In [22]: [part.strip('\'').strip('\"') for part in
> > > > > > > > > > > url[4:].split(',')]
> > > > > > > > > > > Out[22]: ["args=['x", "y']", "vars=dict(z='t')"]
>
> > > > > > > > > > > Just use:
> > > > > > > > > > > elif url.lower().startswith('url:'):
> > > > > > > > > > > url=eval("URL(" + url[4:] + ")")
>
> > > > > > > > > > > This was my first solution, it works well with args and
> > > > > > > > > > > vars.
> > > > > > > > > > > This case works, tested against:
> > > > > > > > > > > Home url:'homepage','plugin_wiki','index'
> > > > > > > > > > > Articles page:articles
> > > > > > > > > > > Links url:'homepage','default','links'
> > > > > > > > > > > Test url:'f',args=['x','y'],vars=dict(z='t')
> > > > > > > > > > > Projects url:'f',args=['x','y']
>
> > > > > > > > > > > Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...
>
> > > > > > > > > > > The only small gotcha is white space absence being
> > > > > > > > > > > required because of
> > > > > > > > > > > the regular expression being used to "parse" the
> > > > > > > > > > > meta-menu lines...
>
> > > > > > > > > > > On Jan 4, 1:13 pm, blackthorne <[email protected]>
> > > > > > > > > > > wrote:
>
> > > > > > > > > > > > That way, you can use URL() to pass args [] and vars {}
> > > > > > > > > > > > under the
> > > > > > > > > > > > web2py way. Have to test it though...
>
> > > > > > > > > > > > On Jan 4, 12:24 pm, mdipierro <[email protected]>
> > > > > > > > > > > > wrote:
>
> > > > > > > > > > > > > but why not simply
>
> > > > > > > > > > > > > url:homepage/plugin_wiki/index
>
> > > > > > > > > > > > > or
>
> > > > > > > > > > > > > localurl:homepage/plugin_wiki/index
>
> > > > > > > > > > > > > and no quotes?
>
> > > > > > > > > > > > > On Jan 4, 6:00 am, blackthorne
> > > > > > > > > > > > > <[email protected]> wrote:
>
> > > > > > > > > > > > > > instead of having common strings ready to be passed
> > > > > > > > > > > > > > as arguments, you
> > > > > > > > > > > > > > would get strings that contain quotes in it. I
> > > > > > > > > > > > > > guess...
>
> > > > > > > > > > > > > > Consider my example:
> > > > > > > > > > > > > > home url:'homepage','plugin_wiki','index'
>
> > > > > > > > > > > > > > you will get:
> > > > > > > > > > > > > > In [9]:
> > > > > > > > > > > > > > url="url:\'homepage\',\'plugin_wiki\',\'index\'"
>
> > > > > > > > > > > > > > In [10]: [part.strip('\'') for part in
> > > > > > > > > > > > > > url[4:].split(',')]
> > > > > > > > > > > > > > Out[10]: ['homepage', 'plugin_wiki', 'index']
>
> > > > > > > > > > > > > > In [11]: [part for part in url[4:].split(',')]
> > > > > > > > > > > > > > Out[11]: ["'homepage'", "'plugin_wiki'", "'index'"]
>
> > > > > > > > > > > > > > Best regards
>
> > > > > > > > > > > > > > On Jan 4, 11:49 am, mdipierro
> > > > > > > > > > > > > > <[email protected]> wrote:
>
> > > > > > > > > > > > > > > Why
>
> > > > > > > > > > > > > > > + elif
> > > > > > > > > > > > > > > url.lower().startswith('url:'):
> > > > > > > > > > > > > > > +
> > > > > > > > > > > > > > > url=URL(*[part.strip('\'') for part in
> > > > > > > > > > > > > > > url[4:].split(',')])
>
> > > > > > > > > > > > > > > and not
>
> > > > > > > > > > > > > > > + elif
> > > > > > > > > > > > > > > url.lower().startswith('url:'):
> > > > > > > > > > > > > > > + url=URL(*[part for part in
> > > > > > > > > > > > > > > url[4:].split(',')])
>
> > > > > > > > > > > > > > > Why the quotes?
>
> > > > > > > > > > > > > > > On Jan 3, 9:07 pm, blackthorne
> > > > > > > > > > > > > > > <[email protected]> wrote:
>
> > > > > > > > > > > > > > > > Because it may not be obvious that the previous
> > > > > > > > > > > > > > > > message includes a
> > > > > > > > > > > > > > > > patch, here is from another
> > > > > > > > > > > > > > > > source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...
>
> > > > > > > > > > > > > > > > thank you
>
> > > > > > > > > > > > > > > > On Jan 4, 2:51 am, Francisco Gama
> > > > > > > > > > > > > > > > <[email protected]> wrote:
>
> > > > > > > > > > > > > > > > > this patch allows you to define custom links
> > > > > > > > > > > > > > > > > using the URL() helper in the meta-menu of
> > > > > > > > > > > > > > > > > plugin_wiki, so you should apply it to:
> > > > > > > > > > > > > > > > > models/plugin_wiki.py
>
> > > > > > > > > > > > > > > > > the syntax used is "Title url:URL_args"
>
> > > > > > > > > > > > > > > > > example:
> > > > > > > > > > > > > > > > > home url:'homepage','plugin_wiki','index'
> > > > > > > > > > > > > > > > > Articles page:articles
> > > > > > > > > > > > > > > > > Links url:'homepage','default','links'
>
> > > > > > > > > > > > > > > > > notice that after "url:" you shall not leave
> > > > > > > > > > > > > > > > > white spaces. This is a must not to touch in
> > > > > > > > > > > > > > > > > the regex currently being used to match that
>
> > > > > > > > > > > > > > > > > Other idea, would be to bring this power to
> > > > > > > > > > > > > > > > > markmin links...
>
> > > > > > > > > > > > > > > > > Leave comments,
> > > > > > > > > > > > > > > > > Best regards
>
> > > > > > > > > > > > > > > > > Francisco Gama Tabanez Ribeiro
>
> > > > > > > > > > > > > > > > > E-mail: [email protected]
> > > > > > > > > > > > > > > > > Twitter: blackthorne
>
>