def delete(self, kind, id): if not kind in kind2model: self.error(500) return if kind == 'settings': return model = kind2model[kind].get_by_id(int(id), parent=User.current()) model.delete()
def getAllData(): result = { 'Vaults': Vault, 'Filters': Filter, 'Payments': Payment, 'T2ps': T2p, 'Tags': Tag } for i in result.keys(): query = result[i].all().ancestor(User.current()) result[i] = [] for entry in query: result[i].append(entry.toDict()) return simplejson.dumps(result)
def post(self, kind, id): if not kind in kind2model: self.error(500) return if kind == 'settings': self.get('settings', id) return data = simplejson.loads(self.request.body) model = kind2model[kind](parent=User.current()) model.fromDict(data) model.put() data = simplejson.dumps(model.toDict()) self.response.out.write(data)
def put(self, kind, id): if not kind in kind2model: self.error(500) return data = simplejson.loads(self.request.body) if kind == 'settings': model = Settings.current() else: model = kind2model[kind].get_by_id(int(id), parent=User.current()) model.fromDict(data) model.put() data = simplejson.dumps(model.toDict()) self.response.out.write(data)
def get(self, kind, id): if kind == 'all': result = self.getAllData() self.response.out.write(result) elif kind == 'settings': result = simplejson.dumps(Settings.current().toDict()) self.response.out.write(result) else: if not kind in kind2model: self.error(500) return result = [] query = kind2model[kind].all().ancestor(User.current()) for item in query: result.append(item.toDict()) result = simplejson.dumps(result) self.response.out.write(result)