- Python Pyramid - Discussion
- Python Pyramid - Useful Resources
- Python Pyramid - Quick Guide
- Python Pyramid - Deployment
- Python Pyramid - Security
- Python Pyramid - Logging
- Python Pyramid - Testing
- Command Line Pyramid
- Creating A Project Manually
- Python Pyramid - Package Structure
- Python Pyramid - Project Structure
- Python Pyramid - Creating A Project
- Python Pyramid - Cookiecutter
- Pyramid - Using SQLAlchemy
- Python Pyramid - Message Flashing
- Python Pyramid - Events
- Python Pyramid - Sessions
- Python Pyramid - Response Object
- Python Pyramid - Request Object
- Python Pyramid - Static Assets
- Pyramid - HTML Form Template
- Python Pyramid - Templates
- Python Pyramid - Route Prefix
- Python Pyramid - View Configuration
- Python Pyramid - Url Routing
- Pyramid - Application Configuration
- Python Pyramid - Hello World
- Pyramid - Environment Setup
- Python Pyramid - Overview
- Python Pyramid - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Python Pyramid - Request Object
The functionapty of a view callable involves obtaining the request data from the WSGI environment and returning a certain HTTP response back to the cpent after processing. The view function receives the Request object as the argument.
Normally this object is not instantiated by the user. Instead, it encapsulates the WSGI environ dictionary. This request object represents "pyramid.request.Request class." It possesses a number of attributes and methods, using which the request data is processed by the view function.
Here are some of the attributes −
request.method − The HTTP request method used by the cpent to send the data, e.g., GET, POST
request.GET − This attribute is a multidict with all the variables in the query string.
request.POST − This attribute is available only if the request was a POST and it is a form submission. It is a multidict with all the variables in the request body.
request.params − A combined multidict of everything in request.GET and request.POST.
request.body − This attribute contains the entire request body as a string. This is useful when the request is a POST that is not a form submission, or a request pke a PUT.
request.cookies − Contains all the cookies.
request.headers − A case-insensitive dictionary of all the HTTP headers.
In addition to the above HTTP specific environment attributes, Pyramid also adds certain special attributes.
request.url − Returns the full request URL with query string, e.g., http://localhost:6543/app?name=Ravi
request.host − The host information in the URL, e.g., localhost
request.host_url − This attribute returns the URL with the host, e.g., http://localhost:6543/
request.apppcation_url − The URL of the apppcation (without PATH_INFO), e.g., http://localhost:6543/app
request.path_url − Contains the URL of the apppcation including the PATH_INFO, e.g., http://localhost:66543/app
request.path − Returns The URL including PATH_INFO without the host, e.g., "/app"
request.path_qs − the query string in the URL including PATH_INFO, e.g., "/app?name=Ravi"
request.query_string − Only the query string in the URL, e.g., "name=Ravi"