def getJson(self): """ Return a JSON object """ r = Json("object") r.add_pair("reactionid", self.name) s = [] for t in self.substrates: s.append(str(self.stoichiometry[t]) + ' ' + self._get_long_name(t)) r.add_pair("reactants", " + ".join(s)) s = [] for t in self.products: s.append(str(self.stoichiometry[t]) + ' ' + self._get_long_name(t)) r.add_pair("products", " + ".join(s)) if self.reversible: r.add_pair("arrow", "<==>") else: r.add_pair("arrow", "===>") ko_label = Json() ko_label.set_label('"ko"') ko_value = Json() if self.ko: ko_value.set_label("true") else: ko_value.set_label("false") r.add_pair(ko_label, ko_value) if self.metabolism: r.add_pair("pathway", self.metabolism) return r
def getJson(self): """ Return a JSON object """ r = Json("object") r.add_pair("reactionid", self.name) s = [] for t in self.substrates: s.append(str(self.stoichiometry[t]) + ' ' + self._get_long_name(t)) r.add_pair("reactants", " + ".join(s)) s = [] for t in self.products: s.append(str(self.stoichiometry[t]) + ' ' + self._get_long_name(t)) r.add_pair("products", " + ".join(s)) if self.reversible: r.add_pair("arrow", "<==>") else: r.add_pair("arrow", "===>") ko_label = Json() ko_label.set_label('"ko"') ko_value = Json() if self.ko: ko_value.set_label("true") else: ko_value.set_label("false") r.add_pair(ko_label, ko_value) if self.metabolism: r.add_pair("pathway", self.metabolism) return r
def newfn(arg): response = Json("object") status_label = Json() status_label.set_label("status") status_indicate_label = Json() status_indicate_label.set_label("0") data_label = Json() data_label.set_label("data") response_label = Json() response_label.set_label("response") response.add_pair(status_label, status_indicate_label) response.add_pair(data_label, f(arg)) result = Json("object") result.add_pair(response_label, response) return result
def newfn(arg): response = Json("object") status_label = Json() status_label.set_label("status") status_indicate_label = Json() status_indicate_label.set_label("0") data_label = Json() data_label.set_label("data") response_label = Json() response_label.set_label("response") response.add_pair(status_label, status_indicate_label) response.add_pair(data_label, f(arg)) result = Json("object") result.add_pair(response_label, response) return result
def newfn(arg): tempresult = f(arg) startRow = int(arg.GET['_startRow']) endRow = int(arg.GET['_endRow']) totalRow = len(tempresult.array_container) if endRow >= totalRow: endRow = totalRow - 1 response = Json("object") status_label = Json() status_label.set_label("status") status_indicate_label = Json() status_indicate_label.set_label("0") response.add_pair(status_label, status_indicate_label) startrow_label = Json() startrow_label.set_label("startRow") startrow_value = Json() startrow_value.set_label(str(startRow)) response.add_pair(startrow_label, startrow_value) endrow_label = Json() endrow_label.set_label("endRow") endrow_value = Json() endrow_value.set_label(str(endRow)) response.add_pair(endrow_label, endrow_value) totalrow_label = Json( ) # note here might be a bug that those labels are not out totalrow_label.set_label("totalRows") totalrow_value = Json() totalrow_value.set_label(str(totalRow)) response.add_pair(totalrow_label, totalrow_value) jarray = tempresult.array_container[startRow:endRow + 1] newjson = Json("array") newjson.array_container = jarray data_label = Json() data_label.set_label("data") response.add_pair(data_label, newjson) result = Json("object") response_label = Json() response_label.set_label("response") result.add_pair(response_label, response) return result
def newfn(arg): tempresult = f(arg) startRow = int(arg.GET['_startRow']) endRow = int(arg.GET['_endRow']) totalRow = len(tempresult.array_container) if endRow >= totalRow: endRow = totalRow - 1 response = Json("object") status_label = Json() status_label.set_label("status") status_indicate_label = Json() status_indicate_label.set_label("0") response.add_pair(status_label, status_indicate_label) startrow_label = Json() startrow_label.set_label("startRow") startrow_value = Json() startrow_value.set_label(str(startRow)) response.add_pair(startrow_label, startrow_value) endrow_label = Json() endrow_label.set_label("endRow") endrow_value = Json() endrow_value.set_label(str(endRow)) response.add_pair(endrow_label, endrow_value) totalrow_label = Json() # note here might be a bug that those labels are not out totalrow_label.set_label("totalRows") totalrow_value = Json() totalrow_value.set_label(str(totalRow)) response.add_pair(totalrow_label, totalrow_value) jarray = tempresult.array_container[startRow:endRow + 1] newjson = Json("array") newjson.array_container = jarray data_label = Json() data_label.set_label("data") response.add_pair(data_label, newjson) result = Json("object") response_label = Json() response_label.set_label("response") result.add_pair(response_label, response) return result