- Deployment Of Application
- CherryPy - Testing
- CherryPy - Demo Application
- CherryPy - Use Of Ajax
- CherryPy - Presentation Layer
- CherryPy - Web Services
- CherryPy - A Working Application
- CherryPy - ToolBox
- Bulit-in Http Server
- CherryPy - Vocabulary
- CherryPy - Environment Setup
- CherryPy - Introduction
- CherryPy - Home
CherryPy Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
CherryPy - Demo Apppcation
In this chapter, we will focus on how an apppcation is created in CherryPy framework.
Consider Photoblog apppcation for the demo apppcation of CherryPy. A Photoblog apppcation is a normal blog but the principal text will be photos in place of text. The main catch of Photoblog apppcation is that the developer can focus more on design and implementation.
Basic Structure – Design of Entities
The entities design the basic structure of an apppcation. The following are the entities for the Photoblog apppcation −
Film
Photo
Album
The following is a basic class diagram for the entity relationship −
Design Structure
As discussed in the previous chapter, the design structure of the project would be as shown in the following screenshot −
Consider the given apppcation, which has sub-directories for Photoblog apppcation. The sub-directories are Photo, Album, and Film which would include controllers.py, models.py and server.py.
Functionally, the Photoblog apppcation will provide APIs to manipulate those entities via the traditional CRUD interface — Create, Retrieve, Update, and Delete.
Connection to the Database
A storage module includes a set of operations; connection with the database being one of the operations.
As it is a complete apppcation, the connection with database is mandatory for API and to maintain the functionapty of Create, Retrieve, Update and Delete.
import dejavu arena = dejavu.Arena() from model import Album, Film, Photo def connect(): conf = { Connect : "host=localhost dbname=Photoblog user=test password=test"} arena.add_store("main", "postgres", conf) arena.register_all(globals())
The arena in the above code will be our interface between the underlying storage manager and the business logic layer.
The connect function adds a storage manager to the arena object for a PostgreSQL RDBMS.
Once, the connection is obtained, we can create forms as per business requirements and complete the working of apppcation.
The most important thing before creation of any apppcation is entity mapping and designing the structure of the apppcation.
Advertisements