>From your original message, I was assuming you did not wish to run a PHP
server at all. If running a PHP server is allowed, it is possible to run
Web2Py and PHP side-by-side, in parallel:

   - http://web2py.relevantmatter.com/welcome/
   - http://web2py.relevantmatter.com/presite/phpinfo.php3
   - The first link is Web2Py; the second link PHP.
   - Internally, everything is hosted on an Apache2 server. Web2Py is
   deployed via Passenger
WSGI<http://wiki.dreamhost.com/Web2py#Passenger_WSGI>,
   which provides a "public" folder that can serve and render PHP content.

For my original question asking about running Web2Py and PHP in serial, I
added the additional requirement that  a single file could contain both
Web2Py and PHP tags. In your case, the parallel method is probably better.

John-Kim

On Sat, Jan 8, 2011 at 10:43 PM, jeff <jef...@gmail.com> wrote:

> I had another idea which is a simplification on my first one : an
> action acting like a proxy on the php server.
> I just wrote a little POC that seems to work.  Here are the few lines
> to put in a controller:
>
> import urllib
>
> def make_get_stuff(an_url):
>    def get_stuff():
>        stuff=urllib.urlopen(an_url)
>        return stuff.read(),stuff.info(),stuff.getcode()
>    return get_stuff
>
> HEADER_TAGS_TO_COPY=("Content-Type","Date","Accept-Ranges","Content-
> Length",
>                     "Etag","Last-Modified","Server","X-Powered-By")
>
> def proxy():
>    stuff_url="http://www.mysite.be/%s?%s"; % (request.url[22:],
> request.env.query_string)
>    stuff_content,stuff_info, stuff_status=cache.ram(stuff_url,
>             lambda: cache.disk(stuff_url,
>
> make_get_stuff(stuff_url),time_expire=None),time_expire=40)
>    for header_tag in HEADER_TAGS_TO_COPY:
>        header_line=stuff_info.getheader(header_tag)
>        if header_line: response.headers[header_tag]=header_line
>    response.status=stuff_status
>    return stuff_content
>
> And I have obviously to write some lines in routes.py like (the proxy
> action is in the w.py controller of the poc app):
>
> (r'.*:http://.*:.* /(?P<any>(?:admin/|poc/).*)',
> r'/\g<any>'),
> (r'.*:http://.*:.* /(?P<any>.*)',
> r'/poc/w/proxy/vars=\g<any>'), # I think that's not used
>
> That seems do the job (and it's quite faaaaaaaast ;-)  ).  I can even
> crawl the old website and it will stand entirely in the cache, I would
> then be able to shut down the php server (providing I manage the 4xx
> errors myself)
>
> Some questions about that solution:
> - are there any drawbacks that I don't see ? (except that the cache
> MUST be managed).
> - what are the headers lines that are better to be copied from the php
> response ? I guess that the only criterion is to please Google and I
> have few clues about their likes and dislikes.  Content-Type must be
> copied, that's for sure, for the others, I don't know and for the ones
> added by web2py : Set-Cookie (session.forget ?), Pragma, Cache-
> Control, ... I don't know if it's better to keep them or not : I don't
> want to foolish Google in a way or another.
> - I could replace the cache (or add that to it) by using the db (mysql
> in prod) to store of the old php site stuffs (pages, images,
> ppt, ...). Any advice ?
>
> Best wishes everybody and thx to all of you : OSS is great, web2py is
> huge and that community is soooooooo cool !
>
>
>
> On Dec 30 2010, 6:07 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> > > My main concerns about this way are:
> > > - the complexity of having runphp working
> >
> > there is no complexity but it is reeeeally slow.
> >
> > > - the work on the templates : I guess that I have to put thephp
> > > templates in the view folder but I don't see exactly what else I have
> > > to do on them
> >
> > Or move them in views/phpand make a web2py controllerphp.py with one
> > action for each file . wiht the instructions above you will be able to
> > inject both web2py tags {{...}} andphptags <?...?>
> >
> > > - do I have to tweak routes.py ? in the same way as above ?
> >
> > It depends on the original files. Probably yes.
> >
> > Why not look at this first:
> >
> > http://www.web2py.com/php
>

Reply via email to