aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers.py')
-rw-r--r--server/helpers.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/server/helpers.py b/server/helpers.py
index 28d15a2..a5977be 100644
--- a/server/helpers.py
+++ b/server/helpers.py
@@ -1,4 +1,6 @@
+import web
+import json
import uuid
import re
from portage.versions import catpkgsplit
@@ -106,3 +108,13 @@ def get_rkey(db, repo):
else:
rkey = db.insert('REPOSITORIES', REPO=repo)
return rkey
+
+def is_json_request():
+ return web.ctx.environ['HTTP_ACCEPT'].find('json') != -1
+
+def serialize(object, human=True):
+ if human:
+ indent = 2
+ else:
+ indent = None
+ return json.JSONEncoder(indent=indent).encode(object)