Introduction💁
Python is a multi-purpose programming language. Its code is mostly emphasized on readability with the usage of a significant amount of indentation.
The CherryPy is a python framework that is used for web application development. CherryPy is used to wrap the HTTP protocols to provide more rapid web development.

CherryPy
Now that we know what cherryPy is, let us look at a few of its advantages and disadvantages.
Advantages
-
CherryPy has various built-in plugins.
-
CherryPy supports various HTTP servers simultaneously.
-
CherryPy provides built-in tools for profiling and testing.
-
CherryPy is HTTP/1.1 compliant and supports a thread pooled WSGI web server.
-
CherryPy provides multiple compatibilities with multiple HTTP servers.
- CherryPy has various built-in tools to perform tasks such as authorization, encoding, sessions, and caching.
Disadvantages
- CherryPy is a fairly outdated framework, thus it is very hard to find documentation for it. Users might have to look for hours to find proper documentation for a particular feature.
Request Parameter Manipulation✨
As we know, all of the data is passed as Strings between two nodes in an HTTP server. Sometimes there arises the need to pass the data as objects for better performance and readability. Thus the developers may use specific tools to convert the data to objects and then pass them between nodes. We will look at similar cases in this blog. We will try and learn how to convert the String into Objects and then we will also look at how to pass them between two or more nodes in an HTTP server.
Converting the data to objects has two major advantages,
-
It provides better performance by transmitting the data in a more efficient way.
- It also provides better readability for the developers and users.
Request Parameter Manipulation is also used for malicious acts such as altering the course of action of the website. Attackers can often use Request Parameter Manipulation to make the website respond in ways it should not. Attackers can modify the website using Request Parameter Manipulation using cookies and HTTP header files. Request Parameter Manipulation is often done with
- Cookies
- Form Fields
- HTTP headers
- URL Query Strings
Example🚀
In this example, let us create an object for the student_id row present in a database and pass it to the page handler.
Note: We are assuming that we have already established a database named db and db has a column named student_id.
import cherrypy
class RequestParameterManipulator(cherrypy.Tool):
def __init__(self):
# declaring a beforehandler hook
cherrypy.Tool.__init__(self, 'before_handler', self.load, priority=10)
def load(self):
# creating an instance of the request function.
req = cherrypy.request
# calling the database db using the created instance
db = req.db
# storing the value of student id in a variable called student_id
student_id = req.params.pop('student_id')
# fetching the value in the database for the corresponding student_id
req.params['user'] = db.get(int(student_id))
cherrypy.tools.user = RequestParameterManipulator()
class Root(object):
# calling the root or / server using cherryPy
@cherrypy.expose
@cherrypy.tools.user()
def index(self, user):
return "hello %s" % user.name
In the above code, we converted the string into an object and passed it to the page handler. We fetched the student details from the database based on the student id and then used the concepts of request parameter manipulation to convert the fetched strings into an object.
Now let's discuss some frequently asked questions associated with Request Parameter Manipulation.





