On Jan 5, 2011, at 2:25 AM, blackthorne wrote:
> 
> ok
> 
> What about the menu option "/Computer /option", wouldn it be caught by
> the same regex currently used?

I haven't been following this thread too closely, but all this stuff should be 
fine in vars. Question marks, slashes, spaces--all ought to be escaped. The 
only problem, IIRC, is '+', since I believe that quote-plus is being used for 
vars.

If the regex doesn't handle it right, the new router will (or I'll fix it).

> 
> 
> On Jan 5, 1:07 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>> No it would not because ? is not allowed in args.
>> 
>> On Jan 4, 5:58 pm, blackthorne <francisco....@gmail.com> wrote:
>> 
>> 
>> 
>>> there I'm just giving you counter-examples that may break that
>>> notation.
>>> On your second question, the / on the right of = would be an argument
>>> 'a' with '/Computer /option' just without quotes as they are optional.
>>> Making a regular expression for that seems very hard, a real parser
>>> would be required.
>> 
>>> My point is that those rules even if well implemented, can fail in
>>> predictable ways.
>> 
>>> So, should I go ahead for it or reconsider other options such as my
>>> suggestion based on newlines?
>> 
>>> On Jan 4, 10:20 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>> 
>>>> I do not understand the notation you propose. Are you suggesting a= to
>>>> specify args? Why the / on the right of =?
>> 
>>>> On Jan 4, 3:55 pm, blackthorne <francisco....@gmail.com> wrote:
>> 
>>>>> what if?
>>>>>   menu item             path               possible arg
>>>>> /Computer_option     /path/function?a=/Computer /option
>>>>> /Computer /option     /path/function?a='/Computer /option'
>>>>> /Computer_option       page:computer
>> 
>>>>> I'm complicating, I know but I'm sure that could find more realistic
>>>>> examples to fit these real possibilities.
>> 
>>>>> On Jan 4, 9:39 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>> 
>>>>>> 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 <francisco....@gmail.com> 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 <mdipie...@cs.depaul.edu> 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 <francisco....@gmail.com> 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 <mdipie...@cs.depaul.edu> wrote:
>> 
>>>>>>>>>> This is a big can of worms... Do we really need to pass vars?
>> 
>>>>>>>>>> On Jan 4, 10:45 am, blackthorne <francisco....@gmail.com> 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 <mdipie...@cs.depaul.edu> wrote:
>> 
>>>>>>>>>>>> Are we still talking about menu links? Why should a menu item 
>>>>>>>>>>>> perform
>>>>>>>>>>>> a post?
>> 
>>>>>>>>>>>> On Jan 4, 10:31 am, blackthorne <francisco....@gmail.com> wrote:
>> 
>>>>>>>>>>>>> fine with me
>> 
>>>>>>>>>>>>> any solution for POST method?
>> 
>>>>>>>>>>>>> On Jan 4, 4:25 pm, mdipierro <mdipie...@cs.depaul.edu> 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 <francisco....@gmail.com> wrote:
>> 
>>>>>>>>>>>>>>> no local urls for secure mode... yes/no?
>> 
>>>>>>>>>>>>>>> On Jan 4, 3:51 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>> 
>>>>>>>>>>>>>>>> There cannot be eval in there. The plugin may be in level=1 
>>>>>>>>>>>>>>>> (secure
>>>>>>>>>>>>>>>> mode).
>> 
>>>>>>>>>>>>>>>> On Jan 4, 8:38 am, blackthorne <francisco....@gmail.com> 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 <francisco....@gmail.com> 
>>>>>>>>>>>>>>>>> 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 <mdipie...@cs.depaul.edu> 
>>>>>>>>>>>>>>>>>> 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 <francisco....@gmail.com> 
>>>>>>>>>>>>>>>>>>> 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 <mdipie...@cs.depaul.edu> 
>>>>>>>>>>>>>>>>>>>> wrote:...
>> 
>> read more ยป


Reply via email to