Changeset 623:6012fe93f78c in documentViewer for SrvTxtUtils.py
- Timestamp:
- Dec 15, 2014, 3:10:05 PM (9 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SrvTxtUtils.py
r622 r623 8 8 import stat 9 9 import urllib 10 from urlparse import urlparse, urlunparse 10 11 import logging 11 12 import time … … 22 23 import xml.etree.ElementTree as ET 23 24 24 srvTxtUtilsVersion = "1.1 2.3"25 srvTxtUtilsVersion = "1.13" 25 26 26 27 map_months = {'en': [u"", … … 371 372 372 373 374 def sslifyUrl(url, app=None, force=False): 375 """returns URL with http or https scheme. 376 377 Looks at app.REQUEST.URL to find the scheme of the current page. 378 Changes only schemeless (starting with //) URLs unless force=True. 379 """ 380 thatUrl = urlparse(url) 381 if hasattr(app, 'REQUEST'): 382 # get current page URL 383 thisUrl = urlparse(app.REQUEST['URL']) 384 if thatUrl.scheme == '': 385 # schemeless URL -> use this scheme 386 return "%s:%s"%(thisUrl.scheme, url) 387 elif force: 388 # use this scheme 389 if thisUrl.scheme != thatUrl.scheme: 390 return urlunparse((thisUrl.scheme,)+thatUrl[1:]) 391 else: 392 # keep scheme 393 return url 394 395 else: 396 # keep scheme 397 return url 398 399 else: 400 # no current page URL 401 if force: 402 # use https for force 403 return urlunparse(('https',)+thatUrl[1:]) 404 405 return url
Note: See TracChangeset
for help on using the changeset viewer.