Skip to content

Commit 43f6f30

Browse files
committed
Add view decorator to set an explicit xkey
1 parent e065831 commit 43f6f30

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pgweb/util/decorators.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ def __cache(request, *_args, **_kwargs):
2424
return _cache
2525

2626

27+
def xkey(key):
28+
"Add a specific xkey to the page, other than the auto-generated ones"
29+
def _xkey(fn):
30+
def __xkey(request, *_args, **_kwargs):
31+
resp = fn(request, *_args, **_kwargs)
32+
if 'xkey' in resp:
33+
resp['xkey'] += ' ' + key
34+
else:
35+
resp['xkey'] = key
36+
return resp
37+
return __xkey
38+
return _xkey
39+
40+
2741
def queryparams(*args):
2842
"""
2943
Allow specified query parameters when calling function.

0 commit comments

Comments
 (0)