Esempio n. 1
0
File: REST.py Progetto: edgiru/mf2
	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()
Esempio n. 2
0
File: REST.py Progetto: edgiru/mf2
	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)
Esempio n. 3
0
File: REST.py Progetto: edgiru/mf2
	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)
Esempio n. 4
0
File: REST.py Progetto: edgiru/mf2
	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)
Esempio n. 5
0
File: REST.py Progetto: edgiru/mf2
	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)