Python 3 Web Development Beginner's Guide

Python 3 Web Development Beginner's Guide: Use Python to create, theme, and deploy unique web applications

Download

Introduction

Building your own Python web applications provides you with the opportunity to have great functionality, with no restrictions. However, creating web applications with Python is not straightforward. Coupled with learning a new skill of developing web applications, you would normally have to learn how to work with a framework as well.

Python 3 Web Development Beginner's Guide shows you how to independently build your own web application that is easy to use, performs smoothly, and is themed to your taste—all without having to learn another web framework.

Web development can take time and is often fiddly to get right. This book will show you how to design and implement a complex program from start to finish. Each chapter looks at a different type of web application, meaning that you will learn about a wide variety of features and how to add them to your customized web application. You will also learn to implement jQuery into your web application to give it extra functionality. By using the right combination of a wide range of tools, you can have a fully functional, complex web application up and running in no time.

A practical guide to building and customizing your own Python web application, without the restriction of a pre-defined framework.

What this book covers
Chapter 1, Choosing Your Tools, looks at the many aspects of designing web applications. The idea is to provide you with an overview that may help you recognize components in subsequent chapters and give you some insight into the arguments used to decide which tool or library to use. We also illustrate some issues that are relevant when designing an application that does not deal with coding directly, such as security or usability.

Chapter 2, Creating a Simple Spreadsheet, develops a simple spreadsheet application. The spreadsheet functionality will be entirely implemented in JavaScript plus jQuery UI, but on the server-side, we will encounter the application server, CherryPy, for the first time and we will extend it with Python code to deliver the page that contains the spreadsheet application dynamically

Chapter 3, Tasklist I: Persistence, a full fledged web application needs functionality to store information on the server and a way to identify different users. In this chapter, we address both issues as we develop a simple application to maintain lists of tasks.

Chapter 4, Tasklist II: Databases and AJAX, refactors the tasklist application developed in the previous chapter. We will use the SQLite database engine on the server to store items and will use jQuery's AJAX functionality to dynamically update the contents of the web application. On the presentation side, we will encounter jQuery UI's event system and will learn how to react on mouse clicks.

Chapter 5, Entities and Relations, most real life applications sport more than one entity and often many of these entities are related. Modeling these relations is one of the strong points of a relational database. In this chapter, we will develop a simple framework to manage these entities and use this framework to build an application to maintain lists of books for multiple users.

Chapter 6, Building a Wiki, develops a wiki application and in doing so we focus on two important concepts in building web applications. The first one is the design of the data layer. The wiki application is quite complex, and in this chapter, we try to see where the limitations in our simple framework lie. The second one is input validation. Any application that accepts input from all over the Internet should check the data it receives, and in this chapter, we look at both client-side and server-side input validation.

Chapter 7, Refactoring Code for Reuse, after doing a substantial bit of work, it is often a good idea to take a step back and look critically at your own work to see if things could have been done better. In this chapter, we look at ways to make the entity framework more generally useful and employ it to implement the books application a second time.

Chapter 8, Managing Customer Relations, there is more to an entity framework and CherryPy application code than merely browsing lists. The user must be able to add new instances and edit existing ones. This chapter is the start of the development of a CRM application that will be extended and refined in the final chapters.

Chapter 9, Creating Full-Fledged Webapps: Implementing Instances, focuses on the design and implementation of the user interface components to add and maintain entities, and relations between entities, in a way that is independent of the type of entity. This functionality is immediately put to use in the CRM application that we develop. Managing user privileges is another issue we encounter as we explore the concept of role-based access control.

Chapter 10, Customizing the CRM Application, is the final chapter and it extends our framework and thereby our CRM application by taking a look at browsing, filtering, and sorting large numbers of entities. We also take a look at what is needed to allow customization by the end user of the application's appearance and its functionality.

What you need for this book
Besides a computer running Windows or Linux to develop and test your applications, you will need the following pieces of open source software:
+ Python 3.2
+ CherryPy 3.2.0
+ jQuery 
+ jQuery UI 1.8.6
How to obtain and install these packages is explained in detail in Chapter 2. We also use some additional plugins for jQuery and provide installation instructions where appropriate. 

Who this book is for 
Moderately experienced Python programmers who want to learn how to create fairly complex, database-driven, cross browser compatible web applications that are maintainable and look good, will find this book of most use. All applications in the book are developed in Python 3, but experience with Python 2.x is sufficient to understand all examples. JavaScript plays an important supporting role in many of the example applications and some introductory level knowledge of JavaScript might be useful, but is not strictly necessary because the focus is mainly on Python development and the JavaScript code is used either as building blocks or explained in such detail that anyone comfortable with Python should be able to understand it.
Share This