Thanks Graham! Tho I have issues understanding what these instructions give me.
My problem is that there are multiple apps running on the same apache server, on the same virtual host. In all of the it is desired that "code.py" is not present in the URL. I figured from reading the source that webpy is using os.environ['REAL_SCRIPT_NAME'] to construct redirect URIs. So i just put os.environ['REAL_SCRIPT_NAME'] = '/~dragan.espenschied/whatever.app' in my code.py at the top. Other code.pys of other apps contain lines with corresponding URI paths. But this seems to affect other webpy apps running on the same apache. If one of these app is called, it constructs redirects to OTHER apps' base URIs, what ever seems to have been accessed before by any other user. The fix from http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive suggest to change the environment variables as well: def application(environ, start_response): # Wrapper to set SCRIPT_NAME to actual mount point. environ['SCRIPT_NAME'] = posixpath.dirname(environ['SCRIPT_NAME']) if environ['SCRIPT_NAME'] == '/': environ['SCRIPT_NAME'] = '' return _application(environ, start_response) So what is the difference to just changing it in the application code? Will this not mix up the environment for other apps as well? Bests, Dragan Looking at the webpy source: application.py ctx.homepath = os.environ.get('REAL_SCRIPT_NAME', env.get('SCRIPT_NAME', '')) ctx.home = ctx.homedomain + ctx.homepath webapi.py: class Redirect(HTTPError): """A `301 Moved Permanently` redirect.""" def __init__(self, url, status='301 Moved Permanently', absolute=False): """ Returns a `status` redirect to the new URL. `url` is joined with the base URL so that things like `redirect("about") will work properly. """ newloc = urlparse.urljoin(ctx.path, url) if newloc.startswith('/'): if absolute: home = ctx.realhome else: home = ctx.home newloc = home + newloc headers = { 'Content-Type': 'text/html', 'Location': newloc } Am 14.12.2010 11:30, schrieb Graham Dumpleton: > The required SCRIPT_NAME fixup and how to do it for that style of redirect is > documented at: > > > http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive > > It is towards the end of that section. > > Graham > > On Tuesday, December 14, 2010 9:10:44 PM UTC+11, drx wrote: > > Dear List, > > I am running an Apache 2.2 with mod_wsgi, with several users, each doing > their > own webpy apps. > > Each user has a similar Apache .htaccess conf in their ~/public_html > directory, > this is mine: > > --- > <Files code.py> > SetHandler wsgi-script > Options ExecCGI FollowSymLinks > </Files> > > RedirectMatch permanent ^(.+)\.app$ $1.app/ > > RewriteEngine On > RewriteBase /~dragan.espenschied/ > RewriteRule ^(.+)\.app/static(.*)$ $1/static$2 [L] > RewriteRule ^(.+)\.app/(.*)$ $1/code.py/$2 <http://code.py/$2> > --- > > It makes that if you call a URI like /~dragan.espenschied/woot.app/ it > will run > /~dragan.espenschied/woot/code.py ... if you don't use the "app" > extension, you > get the usual directory listing. > > Now there are several issues with mod_wsgi, like webpy not being able to > figure > out on its own where its base directory is. That can be avoided, but the > main > issue is concerning redirects. > > If I do a > > --- > raise web.seeother('wherever') > --- > > the browser gets redirected to an URI like > /~dragan.espenschied/woot/code.py/wherever <http://code.py/wherever> > instead of > /~dragan.espenschied/woot.app/wherever > > I figured out that web.seeother is using an environment variable to > prepend the > base URI to a redirect. However, if I change this environment variable > like this > > --- > os.environ['REAL_SCRIPT_NAME'] = '/~dragan.espenschied/woot.app' > -- > > All other webpy apps running on the same server do redirects to my app's > URI > instead to their's. > > What would be a possible way to make the redirects work for multiple > users and > apps on the same server? Is there a better way to tell webpy the base URI > of the > app? > > Running another web server software is not an option, it is a managed > university > system with automatic updates etc (debian). > > > Another issue is the cookies. As already pointed out by some posters > here, the > cookies do not take any path into account. So everybody is reading > everybody > else's cookies. I suggest that webpy should, upon construction, accept a > base > URI parameter, because the automatics don't seem to work under all > conditions. > If there is no base URI parameter present, it could try doing the > automatics as > is. I consider it a bug that webpy seems to assume it is the only app > running on > a system. > > Thanks in advance for any ideas on this, > Dragan > > -- > You received this message because you are subscribed to the Google Groups > "web.py" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/webpy?hl=en. -- http://noobz.cc/ http://digitalfolklore.org/ -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
