You are previewing Python 3 Web Development Beginner's Guide.
O'Reilly logo
Python 3 Web Development Beginner's Guide

Book Description

Use Python to create, theme, and deploy unique web applications

  • Build your own Python web applications from scratch

  • Follow the examples to create a number of different Python-based web applications, including a task list, book database, and wiki application

  • Have the freedom to make your site your own without having to learn another framework

  • Part of Packt's Beginner's Guide Series: practical examples will make it easier for you to get going quickly

In Detail

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 custom 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

Table of Contents

  1. Python 3 Web Development
    1. Python 3 Web Development
    2. Credits
    3. About the Author
    4. About the Reviewers
    5. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Time for action heading
        1. What just happened?
        2. Pop quiz heading
        3. Have a go hero heading
      6. Reader feedback
      7. Customer support
        1. Downloading the example code for this book
        2. Errata
        3. Piracy
        4. Questions
    7. 1. Choosing Your Tools
      1. Identifying the components of a web application
      2. Time for action getting an overview of a web application
        1. What just happened?
      3. Choosing suitable tools
      4. Time for action choosing a delivery framework, also known as web server
        1. What just happened?
      5. Time for action choosing a server-side scripting language
        1. What just happened?
      6. Time for action choosing a database engine
        1. What just happened?
      7. Time for action deciding on object relational mappers
      8. Time for action choosing a presentation framework
        1. What just happened?
      9. Designing for maintainability and usability
        1. Testing
      10. Time for action choosing a test framework
        1. What just happened?
        2. Version management
        3. Usability
          1. Good looking adhering to common GUI paradigms
          2. Themable
          3. Cross-browser compatible
          4. Cross-platform compatible
        4. Maintainability
          1. Standards compliant
        5. Security
          1. Reliable
          2. Robust
          3. Access control and authentication
          4. Confidentiality
          5. Integrity
          6. A final word on security
        6. Help, I am confused!
      11. Time for action maintaining overview
        1. What just happened?
      12. Summary
    8. 2. Creating a Simple Spreadsheet
      1. Python 3
      2. Time for action installing Python 3
        1. What just happened?
      3. CherryPy
      4. Time for action installing CherryPy
        1. What just happened?
      5. Installing jQuery and jQuery UI
      6. Serving an application
      7. Time for action serving a dummy application
        1. What just happened?
      8. Time for action serving HTML as dynamic content
        1. What just happened?
        2. Who serves what: an overview
        3. Pop quiz serving content with CherryPy
        4. HTML: separating form and content
      9. Time for action a unit convertor
        1. What just happened?
        2. HTML: form-based interaction
        3. JavaScript: using jQuery UI widgets
      10. Time for action conversion using unitconverter.js
        1. What just happened?
        2. Pop quiz adding an icon to a button
        3. Have a go hero adding a dynamic title
        4. jQuery selectors
        5. CSS: applying a jQuery UI theme to other elements
        6. Have a go hero adding zebra stripes to a table
      11. Time for action converting a unit convertor into a plugin
        1. What just happened?
        2. Pop quiz adding conversions to a unitconverter instance
        3. JavaScript: creating a jQuery UI plugin
        4. Pop quiz changing option defaults
      12. Designing a spreadsheet application
      13. Time for action serving a spreadsheet application
        1. What just happened?
        2. HTML: keeping it simple
        3. JavaScript: creating a spreadsheet plugin
        4. Have a go hero adding math functions
      14. The missing parts
      15. Summary
    9. 3. Tasklist I: Persistence
      1. Designing a tasklist application
      2. Time for action creating a logon screen
        1. What just happened?
        2. Pop quiz session IDs
        3. Serving a logon screen
        4. Setting up a session
        5. Expiring a session
        6. Have a go hero adding a logon screen to the spreadsheet application
        7. Designing a task list
      3. Time for action running tasklist.py
        1. What just happened?
      4. Python: the task module
      5. Time for action implementing the task module
        1. What just happened?
        2. Adding new tasks
        3. Deleting a task
      6. JavaScript: tasklist.js
      7. Time for action styling the buttons
        1. What just happened?
      8. JavaScript: tooltip.js
      9. Time for action implementing inline labels
        1. What just happened?
        2. CSS: tasklist.css
        3. Pop quiz styling screen elements
        4. Have a go hero changing the date format of a datepicker
        5. Have a go hero serving a task list from a different URL
      10. Summary
    10. 4. Tasklist II: Databases and AJAX
      1. The advantages of a database compared to a filesystem
      2. Choosing a database engine
      3. Database-driven authentication
      4. Time for action authentication using a database
        1. What just happened?
        2. Have a go hero adding new username/passwords
        3. Tasklist II storing tasks in a database
          1. Improving interactivity with AJAX
      5. Time for action getting the time with AJAX
        1. What just happened?
        2. Redesigning the Tasklist application
        3. Database design
      6. Time for action creating the task database
        1. What just happened?
      7. Time for action retrieving information with select statements
        1. What just happened?
        2. Pop quiz using variable selection criteria
        3. TaskDB interfacing with the database
      8. Time for action connecting to the database
        1. What just happened?
      9. Time for action storing and retrieving information
        1. What just happened?
      10. Time for action updating and deleting information
        1. Testing
      11. Time for action testing factorial.py
        1. What just happened?
        2. Now what have we gained?
        3. Pop quiz spotting the error
      12. Time for action writing unit tests for tasklistdb.py
        1. What just happened?
        2. Designing for AJAX
          1. Click handlers
        3. The application
      13. Time for action putting it all together
        1. What just happened?
      14. Have a go hero refreshing the itemlist on a regular basis
      15. Summary
    11. 5. Entities and Relations
      1. Designing a book database
        1. The Entity class
      2. Time for action using the Entity class
        1. What just happened?
        2. Have a go hero checking your input
      3. Time for action creating instances
        1. What just happened?
        2. The Relation class
      4. Time for action using the Relation class
        1. What just happened?
        2. Pop quiz how to check a class
        3. Relation instances
      5. Time for action defining the Books database
        1. What just happened?
        2. Pop quiz how to select a limited number of books
        3. Have a go hero cleaning up the books database
        4. The delivery layer
      6. Time for action designing the delivery layer
        1. What just happened?
      7. Time for action adding a new book
        1. What just happened?
        2. Auto completion
      8. Time for action using input fields with auto completion
        1. What just happened?
        2. The presentation layer
      9. Time for action using an enhanced presentation layer
        1. What just happened?
      10. Summary
    12. 6. Building a Wiki
      1. The data layer
      2. Time for action designing the wiki data model
        1. What just happened?
      3. The delivery layer
      4. Time for action implementing the opening screen
        1. What just happened?
        2. The structural components
        3. The application methods
      5. Time for action implementing a wiki topic screen
        1. What just happened?
      6. Time for action editing wiki topics
        1. What just happened?
        2. Pop quiz
      7. Additional functionality
      8. Time for action selecting an image
        1. What just happened ?
      9. Time for action implementing a tag cloud
        1. What just happened?
      10. Time for action searching for words
        1. What just happened?
      11. The importance of input validation
      12. Time for action scrubbing your content
        1. What just happened?
      13. Time for action rendering content
        1. What just happened?
      14. Summary
    13. 7. Refactoring Code for Reuse
      1. Time for action taking a critical look
        1. What just happened?
      2. Refactoring
      3. Time for action defining new entities: how it should look
        1. What just happened?
        2. Metaclasses
      4. Time for action using metaclasses
        1. What just happened?
        2. MetaEntity and AbstractEntity classes
      5. Time for action implementing the MetaEntity and AbstractEntity classes
        1. What just happened
        2. Have a go hero retrieving instances in a single step
        3. Relations
      6. Time for action defining new relations: how it should look
        1. What just happened?
        2. Implementing the MetaRelation and AbstractRelation classes
          1. Adding new methods to existing classes
        3. Browsing lists of entities
      7. Time for action using a table-based Entity browser
        1. What just happened?
      8. Time for action examining the HTML markup
        1. What just happened?
        2. Caching
      9. The books application revisited
      10. Time for action creating a books application, take two
        1. What just happened?
      11. Summary
    14. 8. Managing Customer Relations
      1. A critical review
      2. Designing a Customer Relationship Management application
      3. Time for action implementing a basic CRM
        1. What just happened?
      4. Adding and editing values
      5. Time for action adding an instance
        1. What just happened?
      6. Time for action editing an instance
        1. What just happened?
      7. Adding relations
      8. Picklists
      9. Time for action implementing picklists
        1. What just happened?
      10. Summary
    15. 9. Creating Full-Fledged Webapps: Implementing Instances
      1. Even more relations
      2. Time for action showing one-to-many relationships
        1. What just happened?
      3. Time for action adapting MetaRelation
        1. What just happened?
      4. Time for action enhancing Display
        1. What just happened?
      5. Time for action enhancing Browse
        1. What just happened?
      6. Access control
      7. Time for action implementing access control
        1. What just happened?
      8. Role-based access control
      9. Time for action implementing role-based access control
        1. What just happened?
      10. Summary
    16. 10. Customizing the CRM Application
      1. Time for action sorting
        1. What just happened?
      2. Time for action filtering
        1. What just happened?
      3. Customization
      4. Time for action customizing entity displays
        1. What just happened?
      5. Time for action customizing entity lists
        1. What just happened?
      6. Time for action adding a delete button
        1. What just happened?
      7. Summary
    17. A. References to Resources
      1. Good old offline reference books
      2. Additional websites, wikis, and blogs
        1. Tools and frameworks
        2. Newsfeeds
    18. B. Pop Quiz Answers
      1. Chapter 2, Creating a Simple Spreadsheet
        1. Serving content with CherryPy
        2. Adding an icon to a button
        3. Adding conversions to a unitconverter instance
        4. Changing option defaults
      2. Chapter 3, Tasklist I: Persistence
        1. Session IDs
        2. Styling screen elements
      3. Chapter 4, Tasklist II: Databases and AJAX
        1. Using variable selection criteria
        2. Spotting the error
      4. Chapter 5, Entities and Relations
        1. How to check a class
        2. How to select a limited number of books
      5. Chapter 6, Building a Wiki
        1. Pop quiz