Ejemplo n.º 1
0
	def my_view(self):
		"""
		"""
		try:
			one = DBSession.query(MyModel).filter(MyModel.name == 'one').first()
		except DBAPIError:
			return Response(conn_err_msg, content_type='text/plain', status_int=500)
		return {'one': one, 'project': 'alchemy_proj'}
Ejemplo n.º 2
0
	def login(self):
		"""
		"""
		print "=====login========self.session========", self.session 
		try:
			user = DBSession.query(User).filter(User.user_name == "saju").first()
			if user:
				self.session["vv"] = user.user_name
				##SM:Check whether session allow to save object.	
				self.session["ss"] = self
				self.session.changed()##Save
		except DBAPIError:
			return Response(conn_err_msg, content_type='text/plain', status_int=500)
		return {"success":True, "msg":"Login success"}
Ejemplo n.º 3
0
	def transaction_test(self):
		"""
		"""
		msg = ""
		try:
			if self.request.params:
				name = self.request.params.get("name")
				trans = self.request.params.get("trans", "1")
			fst = DBSession.query(MyModel).filter(MyModel.name == name).first()
			if fst:
				msg = "row already exist with name:%s" %(name)
			else:
				d = MyModel()
				d.name = name
				d.value = "30"
				DBSession.add(d)
				msg = "Row successfully saved"

				if not int(trans):##Abort/Commit Transaction
					raise Exception("Abort Transaction")

		except DBAPIError:
			return Response(conn_err_msg, content_type='text/plain', status_int=500)
		return {"success":True, "msg":msg}