Beispiel #1
0
 def finish_json(self, errcode=0, errmsg=None, result=None):
     self.set_header("Content-Type", "application/json; charset=UTF-8")
     resp_json = json_encode({
         'errcode': errcode,
         'errmsg': errmsg,
         'result': result
     })
     self.finish(resp_json)
Beispiel #2
0
Datei: views.py Projekt: bcui/sin
def newStore(request,index_name):
  store = ContentStore(name=index_name, sensei_port=random.randint(10000, 15000), brocker_port=random.randint(15000, 20000))
  store.save()
  resp = {
    'id': store.id,
    'name': store.name,
    'sensei_port': store.sensei_port,
    'brocker_port': store.brocker_port,
    'config': store.config,
    'created': store.created,
    'status': store.status,
  }
  return HttpResponse(json.json_encode(resp))
Beispiel #3
0
Datei: views.py Projekt: bcui/sin
def stores(request):
  objs = ContentStore.objects.all()
  resp = [{
      'id': store.id,
      'name': store.name,
      'sensei_port': store.sensei_port,
      'brocker_port': store.brocker_port,
      'config': store.config,
      'created': store.created,
      'status': store.status,
    }
    for store in objs]
  return HttpResponse(json.json_encode(resp))
Beispiel #4
0
Datei: views.py Projekt: bcui/sin
def available(request,index_name):
  resp = {'store':index_name,"available":True}
  return HttpResponse(json.json_encode(resp))
Beispiel #5
0
Datei: views.py Projekt: bcui/sin
def addDoc(request,index_name,id):
  uid = long(id)
  doc = {'id':uid}
  resp = {'store':index_name,'doc':doc}
  return HttpResponse(json.json_encode(resp))
Beispiel #6
0
Datei: views.py Projekt: bcui/sin
def getSize(request,index_name):
  resp = {'store':index_name,"size":0}
  return HttpResponse(json.json_encode(resp))
Beispiel #7
0
 def to_json(self):
     return json_encode({
         'errcode': self.errcode,
         'errmsg': self.errmsg,
     })