def initialize(self):
     self.Resp = Resp()
     url = Config.VALUE["master_url"] + "/host"
     self.http_client = HttpClient(url)
Esempio n. 2
0
 def initialize(self):
     self.Resp = Resp()
     url = Config.VALUE['master_url'] + "/borrow"
     self.http_client = HttpClient(url)
class HostHandler(tornado.web.RequestHandler):
    def initialize(self):
        self.Resp = Resp()
        url = Config.VALUE["master_url"] + "/host"
        self.http_client = HttpClient(url)

    def get(self):
        """
            The GET method is used to get one profile by vid or Profile list
        """
        _method = tools.strip_string(self.get_argument("_method", None))

        if _method == "delete":
            self.delete()
            return

        if _method == "put":
            self.put()
            return

        hostname = tools.strip_string(self.get_argument("hostname", None))

        host = {}
        if hostname != None:
            host["hostname"] = hostname

        resp = self.http_client.get(host)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS and code != RespCode.NO_RECORD:
            failure_reason = resp.get("failure_reason", None)
            self.render("hostManage/error.html", code=resp["response_code_string"], fail_reason=failure_reason)
            return

        if code == RespCode.NO_RECORD:
            self.render("hostManage/viewHosts.html", hosts=None)
            return

        if hostname != None:
            self.render("hostManage/viewHost.html", host=body)
            return

        self.render("hostManage/viewHosts.html", hosts=body)
        return

    def post(self):
        logging.info("Received post body: %s", self.request.body)

        _method = tools.strip_string(self.get_argument("_method", None))
        if _method == "delete":
            self.delete()
            return

        hostname = tools.strip_string(self.get_argument("hostname", None))
        ip = tools.strip_string(self.get_argument("ip", None))

        host = {}
        host["hostname"] = hostname
        host["ip"] = ip

        resp = self.http_client.post(host)
        logging.debug("Response : %s", str(resp))
        (code, file) = self.http_client.resp_handler(resp)
        if code == RespCode.SUCCESS:
            self.redirect("/host")
        else:
            failure_reason = resp.get("failure_reason", None)
            self.render("hostManage/error.html", code=resp["response_code_string"], fail_reason=failure_reason)
        return

    def put(self):
        """
            The put method is used to modify host
        """
        hostname = tools.strip_string(self.get_argument("hostname", None))
        worker_num = tools.to_int(self.get_argument("worker_num", None))

        host = {}
        if hostname != None:
            host["hostname"] = hostname
        if worker_num != None:
            host["worker_num"] = worker_num

        resp = self.http_client.put(host)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get("failure_reason", None)
            self.render("hostManage/error.html", code=resp["response_code_string"], fail_reason=failure_reason)
            return

        self.redirect("/host")
        return

    def delete(self):
        """
            The delete method is used to delete profile
        """
        hostname = tools.strip_string(self.get_argument("hostname", None))

        host = {}
        if hostname != None:
            host["hostname"] = hostname

        resp = self.http_client.delete(host)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get("failure_reason", None)
            self.render("hostManage/error.html", code=resp["response_code_string"], fail_reason=failure_reason)
            return

        self.redirect("/host")
        return
Esempio n. 4
0
	def initialize(self):
		self.Resp = Resp()
		url = Config.VALUE['master_url'] + "/reader"
		self.http_client = HttpClient(url)
		url2 = Config.VALUE['master_url'] + "/borrow"
		self.http_client2 = HttpClient(url2)
Esempio n. 5
0
class BorrowHandler(tornado.web.RequestHandler):
    def initialize(self):
        self.Resp = Resp()
        url = Config.VALUE['master_url'] + "/borrow"
        self.http_client = HttpClient(url)

    def get(self):
        _method = tools.strip_string(self.get_argument('_method', None))

        if _method == 'delete':
            self.delete()
            return

        if _method == 'put':
            self.put()
            return

    def post(self):
        logging.info("received post body: %s", self.request.body)

        bookid = tools.strip_string(self.get_argument("bookid", None))
        readerid = tools.strip_string(self.get_argument('readerid', None))

        borrow = {}
        borrow['bookid'] = bookid
        borrow['readerid'] = readerid

        resp = self.http_client.post(borrow)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render("bookmanage/error.html",
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)

    def put(self):
        logging.info("received renew book: %s", self.request.body)
        bookid = tools.strip_string(self.get_argument('bookid', None))
        borrow = {}
        borrow['bookid'] = bookid

        resp = self.http_client.put(borrow)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render("bookmanage/error.html",
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
        return

        logging.info("renew success!")

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)

        return

    def delete(self):
        logging.info("received post body: %s", self.request.body)

        bookid = tools.strip_string(self.get_argument('bookid', None))
        borrow = {}
        borrow['bookid'] = bookid

        resp = self.http_client.delete(borrow)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render("bookmanage/error.html",
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)
        return
Esempio n. 6
0
class ReaderHandler(tornado.web.RequestHandler):
	def initialize(self):
		self.Resp = Resp()
		url = Config.VALUE['master_url'] + "/reader"
		self.http_client = HttpClient(url)
		url2 = Config.VALUE['master_url'] + "/borrow"
		self.http_client2 = HttpClient(url2)
		
	def get(self):
		_method = tools.strip_string(self.get_argument("_method", None))
		
		if _method == "delete":
			self.delete()
			return
			
		if _method == 'put':
			reader_id = tools.strip_string(self.get_argument('reader_id'))
			self.render("readermanage/updatereader.html", reader_id = reader_id)
			return
			
		reader_id = tools.strip_string(self.get_argument('reader_id'))
		reader = {}
		breader = {}
		
		if reader_id != None:
			reader['reader_id'] = reader_id
			breader['readerid'] = reader_id
			resp = self.http_client.get(reader)
			(code, body) = self.http_client.resp_handler(resp)	
			if code != RespCode.SUCCESS and code != RespCode.NO_RECORD:
				failure_reason = resp.get('failure_reason', None)
				self.render("bookmanage/error.html", code = resp['response_code_string'], fail_reason = failure_reason)
				return
				
			for k,v in body.items():
				reader[k]=v
				
			resp = self.http_client2.get(breader)
			(code, body) = self.http_client2.resp_handler(resp)
			if code == RespCode.SUCCESS:
				reader['book'] = body
			else:
				reader['book'] = None
				
			self.render("readermanage/viewreader.html", reader = reader)
			return
			
			
	def post(self):
		logging.info("received post body: %s", self.request.body)
				
		reader_name = tools.strip_string(self.get_argument('reader_name', None))
		sex = tools.strip_string(self.get_argument('sex', None))
		age = tools.strip_string(self.get_argument('age', None))
		email = tools.strip_string(self.get_argument('email',None))
		type = tools.strip_string(self.get_argument('type', None))
		
		reader = {}
		reader['reader_name'] = reader_name
		reader['sex'] = sex
		reader['age'] = age
		reader['email'] = email
		reader['type'] = type
		
		resp = self.http_client.post(reader)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render('readermanage/error.html', code = resp['response_code_string'], fail_reason =failure_reason)
			return
		
		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'],success_type=success_type)
		return
		
		
	def put(self):
		logging.info("received post body: %s", self.request.body)
		
		_method = tools.strip_string(self.get_argument('_method', None))
		if _method == 'delete':
			self.delete()
			return
			
		reader_id = tools.strip_string(self.get_argument('reader_id', None))
		reader_name = tools.strip_string(self.get_argument('reader_name', None))
		sex = tools.strip_string(self.get_argument('sex', None))
		age = tools.strip_string(self.get_argument('age', None))
		email = tools.strip_string(self.get_argument('email', None))
		type = tools.strip_string(self.get_argument('type', None))
		
		resp = self.http_client.put(reader)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render('readermanage/error.html', code = resp['response_code_string'], fail_reason = failure_reason)
			return
			
		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'],success_type=success_type)
		return
		
	def delete(self):
	
		reader_id = tools.strip_string(self.get_argument('reader_id', None))
		reader = {}
		if reader_id != None:
			reader['reader_id'] = reader_id
		
		resp = self.http_client.delete(reader)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render('readermanage/error.html', code = resp['response_code_string'], fail_reason = failure_reason)
			return
			
		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'],success_type=success_type)
		return
Esempio n. 7
0
class BookHandler(tornado.web.RequestHandler):
    def initialize(self):
        self.Resp = Resp()
        url = Config.VALUE['master_url'] + "/book"
        self.http_client = HttpClient(url)
        url2 = Config.VALUE['master_url'] + "/borrow"
        self.http_client2 = HttpClient(url2)

    def get(self):
        _method = tools.strip_string(self.get_argument('_method', None))

        if _method == 'delete':
            self.delete()
            return

        if _method == 'put':
            book_id = tools.strip_string(self.get_argument('book_id', None))
            self.render("bookmanage/updatebook.html", book_id=book_id)
            return

        book_id = tools.strip_string(self.get_argument('book_id', None))
        book = {}
        bbook = {}
        if book_id != None:
            book['book_id'] = book_id
            bbook['bookid'] = book_id
            resp = self.http_client.get(book)
            (code, body) = self.http_client.resp_handler(resp)
            if code != RespCode.SUCCESS and code != RespCode.NO_RECORD:
                failure_reason = resp.get('failure_reason', None)
                self.render("bookmanage/error.html",
                            code=resp['response_code_string'],
                            fail_reason=failure_reason)
                return

            for k, v in body.items():
                book[k] = v

            resp = self.http_client2.get(bbook)
            (code, body) = self.http_client2.resp_handler(resp)
            if code == RespCode.SUCCESS:
                book['sheet'] = 'no'
                book['returndate'] = body['returndate']
                book['borrowdate'] = body['borrowdate']
            else:
                book['sheet'] = "yes"
                book['returndate'] = None
                book['borrowdate'] = None

            self.render("bookmanage/viewbook.html", book=book)
            return

        se = self.get_argument('_se', None)
        if se == "title":
            book_title = tools.strip_string(self.get_argument('book', None))
            book['book_title'] = book_title
        elif se == "author":
            author = tools.strip_string(self.get_argument('book', None))
            book['author'] = author
        else:
            publisher = tools.strip_string(self.get_argument('book', None))
            book['publisher'] = publisher

#		if book_title != None:
#
#		elif author != None:
#
#		else:
#

        resp = self.http_client.get(book)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS and code != RespCode.NO_RECORD:
            failure_reason = resp.get('failure_reason', None)
            self.render("bookmanage/error.html",
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        if code == RespCode.NO_RECORD:
            self.render("bookmanage/viewbooks.html", books=None)
            return

        self.render("bookmanage/viewbooks.html", books=body)
        return

    def post(self):
        logging.info("received post body: %s", self.request.body)
        book_title = tools.strip_string(self.get_argument('book_title', None))
        author = tools.strip_string(self.get_argument('author', None))
        publisher = tools.strip_string(self.get_argument('publisher', None))
        addr = tools.strip_string(self.get_argument('addr', None))
        description = tools.strip_string(self.get_argument(
            'description', None))
        price = tools.strip_string(self.get_argument('price', None))

        book = {}
        book['book_title'] = book_title
        book['author'] = author
        book['publisher'] = publisher
        book['description'] = description
        book['addr'] = addr
        book['price'] = price

        resp = self.http_client.post(book)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render("bookmanage/error.html",
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)
        return

    def put(self):
        logging.info("received post body: %s", self.request.body)

        book_id = tools.strip_string(self.get_argument('book_id', None))
        book_title = tools.strip_string(self.get_argument('book_title', None))
        author = tools.strip_string(self.get_argument('author', None))
        publisher = tools.strip_string(self.get_argument('publisher', None))
        description = tools.strip_string(self.get_argument(
            'description', None))
        price = tools.strip_string(self.get_argument('price', None))

        book = {}
        book['book_id'] = book_id
        book['book_title'] = book_title
        book['author'] = author
        book['description'] = description

        resp = self.http_client.put(book)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render("bookmanage/error.html",
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)
        return

    def delete(self):

        book_id = tools.strip_string(self.get_argument('book_id', None))

        book = {}
        if book_id != None:
            book['book_id'] = book_id

        resp = self.http_client.delete(book)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render("bookmanage/error.html",
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)
        return
Esempio n. 8
0
class ReaderHandler(tornado.web.RequestHandler):
    def initialize(self):
        self.Resp = Resp()
        url = Config.VALUE['master_url'] + "/reader"
        self.http_client = HttpClient(url)
        url2 = Config.VALUE['master_url'] + "/borrow"
        self.http_client2 = HttpClient(url2)

    def get(self):
        _method = tools.strip_string(self.get_argument("_method", None))

        if _method == "delete":
            self.delete()
            return

        if _method == 'put':
            reader_id = tools.strip_string(self.get_argument('reader_id'))
            self.render("readermanage/updatereader.html", reader_id=reader_id)
            return

        reader_id = tools.strip_string(self.get_argument('reader_id'))
        reader = {}
        breader = {}

        if reader_id != None:
            reader['reader_id'] = reader_id
            breader['readerid'] = reader_id
            resp = self.http_client.get(reader)
            (code, body) = self.http_client.resp_handler(resp)
            if code != RespCode.SUCCESS and code != RespCode.NO_RECORD:
                failure_reason = resp.get('failure_reason', None)
                self.render("bookmanage/error.html",
                            code=resp['response_code_string'],
                            fail_reason=failure_reason)
                return

            for k, v in body.items():
                reader[k] = v

            resp = self.http_client2.get(breader)
            (code, body) = self.http_client2.resp_handler(resp)
            if code == RespCode.SUCCESS:
                reader['book'] = body
            else:
                reader['book'] = None

            self.render("readermanage/viewreader.html", reader=reader)
            return

    def post(self):
        logging.info("received post body: %s", self.request.body)

        reader_name = tools.strip_string(self.get_argument(
            'reader_name', None))
        sex = tools.strip_string(self.get_argument('sex', None))
        age = tools.strip_string(self.get_argument('age', None))
        email = tools.strip_string(self.get_argument('email', None))
        type = tools.strip_string(self.get_argument('type', None))

        reader = {}
        reader['reader_name'] = reader_name
        reader['sex'] = sex
        reader['age'] = age
        reader['email'] = email
        reader['type'] = type

        resp = self.http_client.post(reader)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render('readermanage/error.html',
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)
        return

    def put(self):
        logging.info("received post body: %s", self.request.body)

        _method = tools.strip_string(self.get_argument('_method', None))
        if _method == 'delete':
            self.delete()
            return

        reader_id = tools.strip_string(self.get_argument('reader_id', None))
        reader_name = tools.strip_string(self.get_argument(
            'reader_name', None))
        sex = tools.strip_string(self.get_argument('sex', None))
        age = tools.strip_string(self.get_argument('age', None))
        email = tools.strip_string(self.get_argument('email', None))
        type = tools.strip_string(self.get_argument('type', None))

        resp = self.http_client.put(reader)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render('readermanage/error.html',
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)
        return

    def delete(self):

        reader_id = tools.strip_string(self.get_argument('reader_id', None))
        reader = {}
        if reader_id != None:
            reader['reader_id'] = reader_id

        resp = self.http_client.delete(reader)
        (code, body) = self.http_client.resp_handler(resp)
        if code != RespCode.SUCCESS:
            failure_reason = resp.get('failure_reason', None)
            self.render('readermanage/error.html',
                        code=resp['response_code_string'],
                        fail_reason=failure_reason)
            return

        success_type = resp.get('success_type', None)
        self.render('bookmanage/success.html',
                    code=resp['response_code_string'],
                    success_type=success_type)
        return
Esempio n. 9
0
class BorrowHandler(tornado.web.RequestHandler):
	def initialize(self):
		self.Resp = Resp()
		url = Config.VALUE['master_url'] + "/borrow"
		self.http_client = HttpClient(url)
		
	def get(self):
		_method = tools.strip_string(self.get_argument('_method', None))
		
		if _method == 'delete':
			self.delete()
			return
		
		if _method == 'put':
			self.put()
			return
			
	def post(self):
		logging.info("received post body: %s", self.request.body)
		
		bookid = tools.strip_string(self.get_argument("bookid", None))
		readerid = tools.strip_string(self.get_argument('readerid', None))
		
		borrow = {}
		borrow['bookid'] = bookid
		borrow['readerid'] = readerid
		
		resp = self.http_client.post(borrow)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render("bookmanage/error.html", code=resp['response_code_string'], fail_reason=failure_reason)
			return

		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'],success_type=success_type)
        
	def put(self):
		logging.info("received renew book: %s", self.request.body)
		bookid = tools.strip_string(self.get_argument('bookid', None))
		borrow = {}
		borrow['bookid'] = bookid
		
		resp = self.http_client.put(borrow)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render("bookmanage/error.html", code=resp['response_code_string'], fail_reason=failure_reason)
		return
		
		logging.info("renew success!")

		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'], success_type = success_type)
		
		return
		
		
	def delete(self):
		logging.info("received post body: %s", self.request.body)
	
		bookid = tools.strip_string(self.get_argument('bookid', None))
		borrow = {}
		borrow['bookid'] = bookid
		
		resp = self.http_client.delete(borrow)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render("bookmanage/error.html", code=resp['response_code_string'], fail_reason=failure_reason)
			return

		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'],success_type=success_type)
		return
Esempio n. 10
0
class BookHandler(tornado.web.RequestHandler):
	def initialize(self):
		self.Resp = Resp()
		url = Config.VALUE['master_url'] + "/book"
		self.http_client = HttpClient(url)
		url2 = Config.VALUE['master_url'] + "/borrow"
		self.http_client2 = HttpClient(url2)
		
	
	def get(self):
		_method = tools.strip_string(self.get_argument('_method', None))
		
		if _method == 'delete':
			self.delete()
			return
		
		if _method == 'put':
			book_id=tools.strip_string(self.get_argument('book_id', None))
			self.render("bookmanage/updatebook.html", book_id=book_id)
			return
			
		book_id = tools.strip_string(self.get_argument('book_id', None))
		book = {}
		bbook = {}
		if book_id != None:
			book['book_id'] = book_id
			bbook['bookid'] = book_id
			resp = self.http_client.get(book)
			(code, body) = self.http_client.resp_handler(resp)
			if code != RespCode.SUCCESS and code != RespCode.NO_RECORD:
				failure_reason = resp.get('failure_reason', None)
				self.render("bookmanage/error.html", code=resp['response_code_string'], fail_reason=failure_reason)
				return
			
			for k,v in body.items():
				book[k]=v
			
			resp = self.http_client2.get(bbook)
			(code, body) =self.http_client2.resp_handler(resp)		
			if code == RespCode.SUCCESS:
				book['sheet'] = 'no'
				book['returndate'] = body['returndate']
				book['borrowdate'] = body['borrowdate']
			else:
				book['sheet'] = "yes"
				book['returndate'] = None
				book['borrowdate'] = None
			
			self.render("bookmanage/viewbook.html", book = book)
			return
			
		se = self.get_argument('_se', None)
		if se == "title":  		
			book_title = tools.strip_string(self.get_argument('book', None))
			book['book_title'] = book_title
		elif se == "author":
			author = tools.strip_string(self.get_argument('book', None))
			book['author'] = author
		else:
			publisher = tools.strip_string(self.get_argument('book', None))
			book['publisher'] = publisher
		
#		if book_title != None:
#			
#		elif author != None:
#			
#		else:
#			
			
		resp = self.http_client.get(book)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS and code != RespCode.NO_RECORD:
			failure_reason = resp.get('failure_reason', None)
			self.render("bookmanage/error.html", code=resp['response_code_string'], fail_reason=failure_reason)
			return

		if code == RespCode.NO_RECORD:
			self.render("bookmanage/viewbooks.html",books = None)
			return

		self.render("bookmanage/viewbooks.html", books = body)
		return
           	
           
           	


	def post(self):
		logging.info("received post body: %s", self.request.body)
		book_title = tools.strip_string(self.get_argument('book_title', None))
		author = tools.strip_string(self.get_argument('author', None))
		publisher = tools.strip_string(self.get_argument('publisher', None))
		addr = tools.strip_string(self.get_argument('addr', None))
		description = tools.strip_string(self.get_argument('description', None))
		price = tools.strip_string(self.get_argument('price', None))
		
		book = {}
		book['book_title'] = book_title
		book['author'] = author
		book['publisher'] = publisher
		book['description'] = description
		book['addr'] = addr
		book['price'] = price

		resp = self.http_client.post(book)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render("bookmanage/error.html", code=resp['response_code_string'], fail_reason=failure_reason)
			return
		
		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'],success_type=success_type)
		return




	def put(self):
		logging.info("received post body: %s", self.request.body)
		
		
		book_id = tools.strip_string(self.get_argument('book_id', None))    
		book_title = tools.strip_string(self.get_argument('book_title', None))
		author = tools.strip_string(self.get_argument('author', None))
		publisher = tools.strip_string(self.get_argument('publisher', None))
		description = tools.strip_string(self.get_argument('description', None))
		price = tools.strip_string(self.get_argument('price', None))

		book = {}
		book['book_id'] = book_id
		book['book_title'] = book_title
		book['author'] = author
		book['description'] = description
		
		resp = self.http_client.put(book)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render("bookmanage/error.html", code=resp['response_code_string'], fail_reason=failure_reason)
			return
			
		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'],success_type=success_type)
		return 
		
	def delete(self):

		book_id = tools.strip_string(self.get_argument('book_id', None))

		book = {}
		if book_id != None:
			book['book_id'] = book_id 

		resp = self.http_client.delete(book)
		(code, body) = self.http_client.resp_handler(resp)
		if code != RespCode.SUCCESS:
			failure_reason = resp.get('failure_reason', None)
			self.render("bookmanage/error.html", code=resp['response_code_string'], fail_reason=failure_reason)
			return

		success_type = resp.get('success_type', None)
		self.render('bookmanage/success.html',code=resp['response_code_string'],success_type=success_type)
		return