Exemple #1
0
	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)
Exemple #2
0
	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)