On Thu, Apr 16, 2009 at 12:57 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:
> > A request comes in and you want to redirect it to a controller action > filtering by > - IP of client (for example 127.0.0.1) > - requested protocol (for example http or http "(http|https)"" > - requested hostname (for example www.web2py.com) > - type of request (for example get or post "(get|post)") > - requested URL (for example "/test") > > You would capture it with > > "^[client]:[protocol]://[hostname]:[method] [url]$" Perfect: this was the missing piece (I think)... just one question now: Looking at request vars shown on http://www.web2py.com/examples/simple_examples/hello6. this would match with: (????): client: --> request.client (129.188.33.25) protocol --> actual_server_protocol (HTTP/1.1???) hosthame --> http_x_forwarded_host (www.web2py.com)? http_x_forwarded_server? method --> request_method (GET) url (ahem... this is just part of the url) --> path_info (/examples/simple_examples/hello6) > > in the example > > "^127.0.0.1:(http|https)://www.web2py.com:(get|post) /test" > > Now you can map this into for example "/welcome/default/index" with > routes.py > > routes_in=(("^127.0.0.1:(http|https)://www.web2py.com:(get|post) / > test", "/welcome/default/index"),) > > I can see writing an entire book in this only. > Can you figure out what this does? > > routes_in=(("^127.0.0.1:$a://www.web2py.com:(get|post) /test/$b", "/ > welcome/default/$b?method=$a"),) Yes.. > > > and this? > > routes_in=(("^127.0.0.1:$a://www.web2py.com:(get|post) /test/(? > P<b>.*)", "/welcome/default/$b?method=$a"),) yes ( you can mix references (?P<b>) and $b? Cool!).... > > > I know it is ugly but 1) it works; 2) it very powerful when compared > with routes on rails and urls in Django; 3) is is backward compatible. It's only ugly if it's not obvious - the explanation you provide (at the top) helps A LOT! ;-) > > > Does not anybody remember that I never wanted to add this to web2py? > Now you know why. > > Massimo > > On Apr 16, 12:12 pm, Yarko Tymciurak <yark...@gmail.com> wrote: > > On Thu, Apr 16, 2009 at 11:06 AM, mdipierro <mdipie...@cs.depaul.edu> > wrote: > > > > > Oops... > > > > > This was implemented in 1.61 but with a slightly different syntax than > > > you proposed: > > > > > routes_in=(('^127.0.0.1:https://localhost:post/hello','/admin')) > > > > This is really obtuse, hard to read in an understandable way; > > > > Can you explain more? > > > > > > > > > i.e. re-route all https POST requests from 127.0.0.1 to > > > http_host=="localhost" to /admin. > > > > Huh? *127.0.0.1 maps to "any POST request on HTTPS" --- is that > > correct? > > > > I ask because it reads more like *127.... ---> "any" 127 request > to > > ":https://localhost" > > > > I'm just trying to understand how to parse this with my eyes, make > sense > > of it. > > > > For example, how do I write "any 127.0.0.1 request map > tohttps://localhost"? > > > > And (finally) the "[_space_]/hello", " /admin" mapping.... is not > clear > > to me... not sure what this is saying.. > > Is this any 127 request that is https, that is a post, that roots from > > /hello > > will map to (?) https /admin > > > > A bit confused, > > Yarko > > > > > > > > > This should work with most web server may break in case of proxy. > > > The old syntax is still supported for backward compatibility. > > > > > Massimo > > > > > On Apr 16, 10:36 am, mmlado <mml...@gmail.com> wrote: > > > > bump! > > > > > > Looks like no one, except me, needs this functionality. :( > > > > Or if there's something to fix/change please tell me. > > > > > > regards > > > > mmlado > > > > > > On Mar 19, 7:33 pm, Yarko Tymciurak <yark...@gmail.com> wrote: > > > > > > > Hi Mmlado - > > > > > Welcome, and thanks for the patch. > > > > > > > Massimo is on a trip (and I'm sure he'll look at it soon as he can, > but > > > may > > > > > not be for over a week - not sure if he'll have internet where he > is - > > > ah! > > > > > spring break!). > > > > > > > I'll look at your patch later. > > > > > > > Looking forward to hearing more from you! > > > > > > > Regards, > > > > > Yarko > > > > > > > On Thu, Mar 19, 2009 at 11:56 AM, Mladen Milankovic < > mml...@gmail.com > > > >wrote: > > > > > > > > Hi. > > > > > > > > My name is Mladen Milankovic, and I'm a first time poster. I've > been > > > > > > working > > > > > > with web2py for a couple of months (reading mailing list from > that > > > time), > > > > > > and > > > > > > around a year with python. > > > > > > > > I like writing applications in web2py, because it's easy and > fast... > > > I came > > > > > > from php. :) > > > > > > > > Wanted to use web2py through apache. At first I used it through > > > mod_proxy, > > > > > > but > > > > > > wanted to go to wsgi. I manage several domain names and needed to > > > access > > > > > > different application from web2py as if they run through the > root, > > > without > > > > > > the > > > > > > application/controller/function. I managed to make it work like > > > needed > > > > > > through > > > > > > mod_proxy, but rewrite through wsgi was hard for me. routes.py > was > > > much > > > > > > easier, at least for me, but I could only setup one set of > rewrite > > > > > > instructions in it. > > > > > > > > I saw AchipAs post in "web2py and GAE" thread about modifying the > > > routes.py > > > > > > so > > > > > > it can be given parameter about host, so different host names > have > > > > > > different > > > > > > rewrite instructions. Unfortunately this was the last post I saw > > > about this > > > > > > topic. > > > > > > > > Thought to give it a try and write a patch that will do that. I > > > tested it > > > > > > directly and through proxy and wsgi. It's backward compatible. > Didn't > > > have > > > > > > any > > > > > > problems with it. Further testing needed. > > > > > > > > I went with AchipAs solution of third parameter to every rewrite > > > > > > instruction: > > > > > > example > > > > > > routes_in = (('.*:/favicon.ico', '/examples/static/favicon.ico'), > > > > > > ('.*:/robots.txt', '/examples/static/robots.txt'), > > > > > > ('.*:/robots.txt', '/myapp/static/robots.txt', ' > > > mydomain.com > > > > > > '), > > > > > > ('.*:/', '/myapp/default/index', 'mydomain.com') > > > > > > ) > > > > > > Now when /robots.txt is called through mydomain.com it will give > the > > > one > > > > > > from > > > > > > /myapp/static/, and when called through any other the one from > > > > > > /examples/static/. Also mydomain.com/ will give > /myapp/default/index > > > page. > > > > > > Same rules apply for routes_out and routes_onerror. Host name can > be > > > > > > written > > > > > > in regular expression, and instructions with host name will be > > > prioritized. > > > > > > They will be checked first. > > > > > > > > Modified files: > > > > > > /gloun/rewrite.py > > > > > > /gluon/main.py > > > > > > > > Unfortunately, had to modify gluon/main.py, too. It contains > > > > > > check_error_route > > > > > > function, as I read in the comment because of IE. Tried it only > with > > > > > > Firefox. > > > > > > > > Found on net how to create svn patch. It created against svn, > > > revision 796. > > > > > > > > regards > > > > > > mmlado > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---