On 2011-09-29 10:44 +0700, michael kapelko wrote:
> Hi.
> My app is served at http://IP/wsm/ for production, for testing I use
> test web server and thus my app is served at http://IP:8080/
> I'm forced to employ global "urlPrefix" variable and construct all
> links with that variable.
> 
> I want the test server to serve my app at http://IP:8080/wsm/ so that
> I don't need to change urlPrefix when either deploying, or testing. Is
> there a way to do it?
> Thanks.

Here's one way you could do it:

    >>> import os
    >>> urlPrefix = os.environ['APP_PREFIX'] or '/prefix'
    >>> urls = ('/foo', 'foo', '/bar', 'bar')
    >>> urls = map(lambda x: x[0] == '/' and urlPrefix + x or x, urls)
    >>> urls
    ['/prefix/foo', 'foo', '/prefix/bar', 'bar']
    >>> 

-- 
Branko Vukelic
[email protected]
[email protected]

IDEA MACHINE
www.brankovukelic.com

Lead Developer
Herd Hound (tm) - Travel that doesn't bite
www.herdhound.com

Love coffee? You might love Loveffee, too.
loveffee.appspot.com

-- 
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.

Reply via email to