Download:
child 64:e7239f626bf2
parent 62:fe5e2ab8ca2d
63:8550f1a5ad61
Anton Shestakov <av6@dwimlabs.net>, Mon, 18 Jul 2016 18:44:12 +0800
viewer: move urlencode() out of BaseHandler to module level

1 файлов изменено, 9 вставок(+), 8 удалений(-) [+]
viewer.py file | annotate | diff | comparison | revisions
--- a/viewer.py Mon Jul 18 18:38:43 2016 +0800
+++ b/viewer.py Mon Jul 18 18:44:12 2016 +0800
@@ -36,6 +36,12 @@
return user
+def urlencode(**kwargs):
+ def joinparams(params):
+ return ','.join(quote_plus(i, '(),') for i in params)
+ return '&'.join(quote_plus(k) + '=' + joinparams(v) for k, v in kwargs.items())
+
+
class BaseHandler(RequestHandler):
def prepare(self):
self.conn = sqlite3.connect(DBPATH)
@@ -173,11 +179,6 @@
self.write(line)
self.finish()
- def urlencode(self, **kwargs):
- def joinparams(params):
- return ','.join(quote_plus(i, '(),') for i in params)
- return '&'.join(quote_plus(k) + '=' + joinparams(v) for k, v in kwargs.items())
-
def setlocal(self, value=None):
kwargs = self.request.arguments.copy()
if value is None:
@@ -188,7 +189,7 @@
else:
kwargs['local'] = [str(value)]
if kwargs:
- return '?' + self.urlencode(**kwargs)
+ return '?' + urlencode(**kwargs)
else:
return self.request.path
@@ -202,7 +203,7 @@
else:
kwargs['rev'] = ['rev({})'.format(value)]
if kwargs:
- return '?' + self.urlencode(**kwargs)
+ return '?' + urlencode(**kwargs)
else:
return self.request.path
@@ -221,7 +222,7 @@
except KeyError:
pass
if kwargs:
- return '?' + self.urlencode(**kwargs)
+ return '?' + urlencode(**kwargs)
else:
return self.request.path
return fn