This is Pluto, the webhook server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
742 B

import json
def header_dumps(hdr):
return '\n'.join('%s: %s'%(k, v) for k, v in hdr.items())
def header_loads(hdr):
d = {}
for line in hdr.split('\n'):
k, _, v = line.partition(': ')
if _:
d[k] = v
return d
def jloads(s):
return json.loads(s)
except (ValueError, TypeError):
return s
def jdumps(obj):
return json.dumps(obj)
except (ValueError, TypeError):
return obj
def checkbox(request, name):
return (True if request.values.get(name, 0, int) else False)
def safe_load(tpn, rowid):
import model
return getattr(model, tpn).get_one(rowid=rowid)
except (AttributeError, model.DBError):
return None