Browse code
...
Ed L authored on 05/03/2012 18:34:11
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -31,6 +31,7 @@ import collections |
31 | 31 |
################### Customization hooks |
32 | 32 |
class EventHandler(object): |
33 | 33 |
external_port = None |
34 |
+ url = None |
|
34 | 35 |
|
35 | 36 |
@property |
36 | 37 |
def store(self): |
... | ... |
@@ -299,29 +300,32 @@ class OpenIDResource(Resource): |
299 | 300 |
def buildURL(self, txrequest, action='', **query): |
300 | 301 |
"""Build a URL relative to the server base_url, with the given |
301 | 302 |
query parameters added.""" |
302 |
- a = urlparse.urlparse(txrequest.prePathURL()+'/') |
|
303 |
+ base = self.eventhandler.url |
|
304 |
+ if not base: |
|
305 |
+ a = urlparse.urlparse(txrequest.prePathURL()+'/') |
|
306 |
+ |
|
307 |
+ port = a.port |
|
308 |
+ if self.eventhandler.external_port: |
|
309 |
+ port = self.eventhandler.external_port |
|
310 |
+ if port == 80: |
|
311 |
+ port = '' |
|
312 |
+ else: |
|
313 |
+ port = ':%s' % port |
|
314 |
+ |
|
315 |
+ url = urlparse.SplitResult( |
|
316 |
+ a.scheme, |
|
317 |
+ '%s:%s@%s%s' % ( |
|
318 |
+ a.username, |
|
319 |
+ a.password, |
|
320 |
+ a.hostname, |
|
321 |
+ port |
|
322 |
+ ), |
|
323 |
+ a.path, |
|
324 |
+ a.query, |
|
325 |
+ a.fragment) |
|
326 |
+ |
|
327 |
+ base = url.geturl() |
|
303 | 328 |
|
304 |
- port = a.port |
|
305 |
- if self.eventhandler.external_port: |
|
306 |
- port = self.eventhandler.external_port |
|
307 |
- if port == 80: |
|
308 |
- port = '' |
|
309 |
- else: |
|
310 |
- port = ':%s' % port |
|
311 |
- |
|
312 |
- url = urlparse.SplitResult( |
|
313 |
- a.scheme, |
|
314 |
- '%s:%s@%s%s' % ( |
|
315 |
- a.username, |
|
316 |
- a.password, |
|
317 |
- a.hostname, |
|
318 |
- port |
|
319 |
- ), |
|
320 |
- a.path, |
|
321 |
- a.query, |
|
322 |
- a.fragment) |
|
323 |
- |
|
324 |
- base = url.geturl() |
|
325 | 329 |
if action: |
326 | 330 |
base = urlparse.urljoin(url.geturl(), action) |
327 | 331 |
print 'buildURL', base |