def deletedoc(docid): bokehuser = bokeh_app.current_user() try: bokehuser.remove_doc(docid) bokehuser.save(bokeh_app.servermodel_storage) except DataIntegrityException as e: return abort(409, e.message) jsonstring = protocol.serialize_web(bokehuser.to_public_json()) msg = protocol.serialize_web({'msgtype' : 'docchange'}) bokeh_app.publisher.send("bokehuser:" + bokehuser.username, msg) return make_json(jsonstring)
def deletedoc(request): docid = request.matchdict['docid'] bokehuser = request.current_user() try: bokehuser.remove_doc(docid) bokehuser.save(request.registry.servermodel_storage) except DataIntegrityException as e: return HTTPConflict(e.message) jsonstring = protocol.serialize_web(bokehuser.to_public_json()) msg = protocol.serialize_web({'msgtype' : 'docchange'}) request.registry.publisher.send("bokehuser:" + bokehuser.username, msg) return jsonstring
def makedoc(): if request.json: title = request.json['title'] else: title = request.values['title'] bokehuser = bokeh_app.current_user() try: _makedoc(bokeh_app.servermodel_storage, bokehuser, title) except DataIntegrityException as e: return abort(409, e.message) jsonstring = protocol.serialize_web(bokehuser.to_public_json()) msg = protocol.serialize_web({'msgtype' : 'docchange'}) bokeh_app.publisher.send("bokehuser:" + bokehuser.username, msg) return make_json(jsonstring)
def makedoc(request): json_body = request.json_body if json_body: title = json_body['title'] else: title = request.params['title'] bokehuser = request.current_user() try: _makedoc(request.registry.servermodel_storage, bokehuser, title) except DataIntegrityException as e: return HTTPConflict(e.message) jsonstring = protocol.serialize_web(bokehuser.to_public_json()) msg = protocol.serialize_web({'msgtype' : 'docchange'}) request.registry.publisher.send("bokehuser:" + bokehuser.username, msg) return jsonstring
def make_doc(self, title): url = urlparse.urljoin(self.root_url,"/bokeh/doc/") data = protocol.serialize_web({'title' : title}) response = self.http_session.post(url, data=data, verify=False) if response.status_code == 409: raise DataIntegrityException self.userinfo = utils.get_json(response)
def on_message(self, message): msgobj = protocol.deserialize_json(message) msgtype = msgobj.get('msgtype') if msgtype == 'subscribe': auth = msgobj['auth'] topic = msgobj['topic'] if self.manager.auth(auth, topic): self.manager.subscribe(self.clientid, topic) msg = protocol.serialize_json( protocol.status_obj(['subscribesuccess', topic, self.clientid]) ) self.write_message(topic + ":" + msg) else: msg = protocol.serialize_web(protocol.error_obj('unauthorized')) self.write_message(topic + ":" + msg)
def doc_by_title(): if request.json: title = request.json['title'] else: title = request.values['title'] bokehuser = bokeh_app.current_user() docs = [doc for doc in bokehuser.docs if doc['title'] == title] if len(docs) == 0: try: doc = _makedoc(bokeh_app.servermodel_storage, bokehuser, title) docid = doc.docid except DataIntegrityException as e: return abort(409, e.message) msg = protocol.serialize_web({'msgtype' : 'docchange'}) bokeh_app.publisher.send("bokehuser:" + bokehuser.username, msg) else: doc = docs[0] docid = doc['docid'] return get_bokeh_info(docid)
def doc_by_title(request): json_body = request.json_body if json_body: title = json_body['title'] else: title = request.params['title'] bokehuser = request.current_user() docs = [doc for doc in bokehuser.docs if doc['title'] == title] if len(docs) == 0: try: doc = _makedoc( request, request.registry.servermodel_storage, bokehuser, title ) docid = doc.docid except DataIntegrityException as e: return HTTPConflict(e.message) msg = protocol.serialize_web({'msgtype' : 'docchange'}) request.registry.publisher.send("bokehuser:" + bokehuser.username, msg) else: doc = docs[0] docid = doc['docid'] return _get_bokeh_info(request, docid)
def get_user(): bokehuser = bokeh_app.current_user() if not bokehuser: abort(403) content = protocol.serialize_web(bokehuser.to_public_json()) return make_json(content)
def get_user(): bokehuser = bokeh_app.current_user() content = protocol.serialize_web(bokehuser.to_public_json()) return make_json(content)
def bbset(self, client, key, model): return client.set(key, protocol.serialize_web( model.to_json(include_hidden=True)))
def get_user(request): bokehuser = request.current_user() content = protocol.serialize_web(bokehuser.to_public_json()) return content