def post(self, *args):
        if not self.api_key.can_create_key():
            raise HTTPError(403)

        try:
            api_key, data, parent = self.fetch_key()
        except __HOLE__:
            raise HTTPError(400)

        permissions = data.get('permissions', {})
        if permissions.get('admin') == True and not self.api_key.is_admin():
            raise HTTPError(403)

        try:
            self.key_mgr.set_key(api_key, data, parent=parent)
        except KeyConflict:
            raise HTTPError(409)

        location = '%s://%s/keys/%s' % (self.request.protocol,
                self.request.host, api_key)

        self.set_header("Content-Type", "application/json")
        self.set_header("X-Api-Key", api_key)
        self.set_header("Location", location)
        self.write(json.dumps({"ok": True, "api_key": api_key}))
dataset/ETHPy150Open benoitc/gaffer/gaffer/gafferd/http_handlers/keys.py/KeysHandler.post