diff options
author | Simo Sorce <simo@redhat.com> | 2015-01-12 15:02:18 -0500 |
---|---|---|
committer | Patrick Uiterwijk <puiterwijk@redhat.com> | 2015-01-16 10:33:22 +0100 |
commit | d6ffbfe04bc6b6370e3aa112e7bdd7183a851a94 (patch) | |
tree | 90079c515153765db4c827c41f3bc5bcc2ccf828 /ipsilon/util/page.py | |
parent | 45cb73a21a90084818c3057e362ef9459f1600f3 (diff) | |
download | ipsilon-d6ffbfe04bc6b6370e3aa112e7bdd7183a851a94.tar.gz ipsilon-d6ffbfe04bc6b6370e3aa112e7bdd7183a851a94.tar.xz ipsilon-d6ffbfe04bc6b6370e3aa112e7bdd7183a851a94.zip |
Use referer too as source of transaction IDs
This allows us to use apache module that use things like ErrorDocument
directives to do internal redirects and still retain the original
transaction intact.
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Diffstat (limited to 'ipsilon/util/page.py')
-rw-r--r-- | ipsilon/util/page.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ipsilon/util/page.py b/ipsilon/util/page.py index db1c145..0929961 100644 --- a/ipsilon/util/page.py +++ b/ipsilon/util/page.py @@ -22,9 +22,11 @@ from ipsilon.util.trans import Transaction from urllib import unquote try: from urlparse import urlparse + from urlparse import parse_qs except ImportError: # pylint: disable=no-name-in-module, import-error from urllib.parse import urlparse + from urllib.parse import parse_qs def admin_protect(fn): @@ -123,7 +125,18 @@ class Page(Log): def get_valid_transaction(self, provider, **kwargs): try: - return Transaction(provider, **kwargs) + t = Transaction(provider) + # Try with kwargs first + tid = t.find_tid(kwargs) + if not tid: + # If no TID yet See if we have it in a referer + if 'referer' in cherrypy.request.headers: + r = urlparse(unquote(cherrypy.request.headers['referer'])) + if r.query: + tid = t.find_tid(parse_qs(r.query)) + if not tid: + t.create_tid() + return t except ValueError: msg = 'Transaction expired, or cookies not available' raise cherrypy.HTTPError(401, msg) |