Changeset 3561 for framework

Show
Ignore:
Timestamp:
06/08/10 09:52:10 (2 years ago)
Author:
aabt
Message:

add new baseurl param to print services to simplify dealing with proxies. p=me,elemoine r=elemoine,me (closes #574)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • framework/server/trunk/mapfish/controllers/printer.py

    r3512 r3561  
    2727import re 
    2828import simplejson 
     29import urlparse 
    2930 
    3031from pylons.controllers import WSGIController 
     
    207208        """ 
    208209        actionUrl = url(controller="printer", action=actionName, id=id) 
     210 
     211        # in 2.0 we'll support "baseurl" only, so the following code 
     212        # block will be removed. And the fromAction argument of this 
     213        # function will also be removed. 
    209214        if request.params.has_key('url'): 
    210215            fullUrl = request.params['url'].encode('utf8') 
     
    215220                return fullUrl[0:-len(myUrl)] + actionUrl 
    216221            log.warn("Cannot guess the base URL for " + fullUrl + " (action=" + myUrl + ")") 
    217         return request.scheme + "://" + request.host + actionUrl 
     222 
     223        if request.params.has_key('baseurl'): 
     224            return request.params['baseurl'].encode('utf8') + actionUrl.split('/')[-1] 
     225        return urlparse.urlunparse((request.scheme, request.host, actionUrl, None, None, None)) 
    218226 
    219227    def _addURLs(self, json):