Each week will have in-class lectures, lab time, and lightning talks. There will be recommended reading, additional reading for the curious, and an assignment to be completed.
Date: Jan. 8, 2013
In this class, we will discuss the fundamental concepts and structures that underly the internet and networked computing. We will learn about the TCP/IP stack (Internet Protocol Suite) and gain insight into how that model is manifested in real life. We will learn about sockets and how to use them to communicate between processes on a single machine or across a network.
Our class laboratory will focus on creating a small server-client program that demonstrates the use of sockets. We will install the server on our Virtual Machines, and accomplish our first networked communication.
The class assignment will focus on extending our use of sockets to support a more complex use-case.
- Wikipedia - Internet Protocol Suite
- Kessler - TCP/IP (sections 1 and 2)
- Wikipedia - Domain Name System
- Wikipedia - Internet Sockets
- RFC 5321 - SMTP (Appendix D only)
For our in-class lab and our homework, you'll be forking a github repository and making pull requests. You can read up on how this is accomplished here:
- Python Module of the Week - socket
- Wikipedia - Berkeley socket interface
- RFC 821 - SMTP (initial)
- RFC 5321 - SMTP (latest)
ZeroMQ Guide, Chapter 1: ZeroMQ is a modern, advanced implementation of the socket concept. Read this to find out what sockets can get up to these days.
You can read the assignment at
http://github.com/cewing/training.python_web/blob/master/assignments/week01/athome/assignment.txt
Please complete the assignment by noon on Sunday, January 13, 2013.
Date: Jan. 15, 2013
In this class we will discuss the various languages of the Internet. What differentiates one protocol from another? How are they similar? How can you use the inherent qualities of each to determine which is appropriate for a given purpose?
The class laboratory will cover creating a simple web server. Using the HTTP protocol and information we learned in week one about sockets, we'll create a simple web server that allows us to look at files and directories on our own computers.
The class assignment will be to extend the simple web server, adding the ability to run dynamic processes and return the results to the client.
Read through the list of Python Internet Protocols. If you don't know what a protocol is for, look it up online. Think about their relationship to each other, which are clients? Which are servers? Which clients talk to which servers?
Python Standard Library Internet Protocols
An introduction to the HTTP protocol: HTTP Made Really Easy
Skim these before class, you'll need them for lab and your assignment:
- httplib2 - A comprehensive HTTP client library that supports many features left out of other HTTP libraries.
- requests - "... an Apache2 Licensed HTTP library, written in Python, for human beings."
Skim these four documents from different phases of HTTP's life. Get a feel for how the specification has changed (and how it hasn't!).
- HTTP/0.9
- HTTP - as defined in 1992
- Hypertext Transfer Protocol -- HTTP/1.0
- Hypertext Transfer Protocol -- HTTP/1.1
If you have more curiosity about other Python Standard Library implementations of internet protocols, you should read Doug Hellmann's Python Module Of The Week on Internet Protocols and Support. His entries on these libraries are clear and concise and have some great code examples.
You can read the assignment at
http://github.com/cewing/training.python_web/blob/master/assignments/week02/athome/assignment.txt
Please complete the assignment by noon on Sunday, January 20, 2013.
Date: Jan. 22, 2013
In this class we will explore some of the ways that you can consume and explore the data provided by other websites. Online data can be provided in ways intended for consumption. But you can also use scraping techniques to get at data the original author may not have considered valuable enough to present as consumable.
We'll explore the use of tools like BeautifulSoup to help make sense of the truly horrible HTML that is to be found in the wild. We will also look at "Web Services" formats like XMLRPC and REST so we can understand the ways in which we can find data, or present it ourselves. Finally, we'll look at some "Web Service APIs" to help understand how to read them, and how to use them to get at the data they provide.
In our class lab sessions we will practice scraping a website and using a documented web service API.
For our class assignment, students will choose two (or more) sources of information online and combine them in a mashup.
- Wikipedia's take on 'Web Services'
- xmlrpc overview
- xmlrpc spec (short)
- json overview and spec (short)
- How I Explained REST to My Wife (Tomayko 2004)
- A Brief Introduction to REST (Tilkov 2007)
- Why HATEOAS - *a simple case study on the often ignored REST constraint*
- BeautifulSoup - "You didn't write that awful page. You're just trying to get some data out of it. Right now, you don't really care what HTML is supposed to look like. Neither does this parser."
- httplib2 - A comprehensive HTTP client library that supports many features left out of other HTTP libraries.
- restkit - an HTTP resource kit for Python. It allows you to easily access to HTTP resource and build objects around it.
- rpclib - a simple, easily extendible soap library that provides several useful tools for creating, publishing and consuming soap web services
- Suds - a lightweight SOAP python client for consuming Web Services.
- the SOAP specification
- Wikipedia on REST <http://en.wikipedia.org/wiki/Representational_State_Transfer>
- Original REST disertation <http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm>
You can read the assignment at
http://github.com/cewing/training.python_web/blob/master/assignments/week03/athome/assignment.txt
Please complete the assignment by noon on Sunday, January 27, 2013.
Date: Jan. 29, 2013
In this class we will explore ways of moving data from HTTP requests into the dynamic scripts that process data. We will begin by looking at the original specification for passing data, CGI (Common Gateway Interface). We'll look at the benefits and drawbacks of the specification, and use it to create some simple interactions.
Then we will investigate a more modern take on the same problem, WSGI (Web Services Gateway Interface). We'll see the ways in which WSGI is similar to CGI, and look at the ways in which it differs. We'll create a simple interaction using WSGI and see what benefits and drawbacks it confers.
- CGI tutorial - Read the following sections: Hello World, Debugging, Form. Other sections optional. Follow along, hosting CGI scripts either via Apache on our VMs, or locally using CGIHTTPServer.
- WSGI tutorial - Follow along, hosting WSGI scripts either via Apache on our VMs, or locally using wsgiref.
- CGI example scripts - Use these examples to get started experimenting with CGI.
- CGI module - utilities for CGI scripts, mostly form and query string parsing
- Parse URLS into components
- CGIHTTPServer - python -m CGIHTTPServer
- WSGI Utilities and Reference implementation
- WSGI 1.0 specification
- WSGI 1.0.1 (Python 3 support)
- test WSGI server, like cgi.test()
- Getting Started with WSGI - by Armin Ronacher (really solid and quick!)
- very minimal introduction to WSGI
You can read the assignment at
http://github.com/cewing/training.python_web/blob/master/assignments/week04/athome/assignment.txt
Please complete the assignment by noon on Sunday, February 3, 2013.
Date: Feb. 5, 2013
In this class we learn about using frameworks to help us reach our goals. We will learn what makes up a framework and some criteria for evaluating which is the right one for you.
This week we will also learn about the final project for the class and students will begin to think about what they wish to do to complete the project.
In our class lab we will explore using a specific framework (Flask) to create a simple web application. We'll learn how to install the framework, how to read the documentation for it, how to build a simple dynamic application, and how to push further on.
For our assignment we will extend our knowledge by trying out a different framework. We will have the chance to repeat the class lab, or create another dynamic system using one of the many other python web frameworks available to us.
- Web Application Frameworks
- Flask Documentation - Read the Foreward, Installation and Quickstart sections.
- Unittest - Unit Testing Framework - We will be writing tests from here forward. Start learning how.
Please also skim this:
- sqlite3 - DB API for sqlite3 - We'll need a bit of familiarity with the sqlite3 module. How to open connections, execute queries, and read the results from a cursor. Just read the first two sections ('Creating a Database' and 'Retrieving Data').
- Install Flask in a virtualenv on your local machine.
- Walk through the examples in the Quickstart section.
- You can play with the tutorial if you want. We'll be doing this in class as our lab work
- Bottle: Python Web Framework
- CherryPy: A Minimalize Python Web Framework
- Web.py: Think about the ideal way to write a web app. Write the code to make it happen.
These are only a few of the many python web frameworks available in the 'microframework' class. I offer these resources as a starting point. For your assignment, pick one of these to work with, or select one from the list at the python wiki below. Do Not Use Django or Pyramid. We will be covering those specifically in class.
You may also want to do more reading on the unittest module:
You can read the assignment at
http://github.com/cewing/training.python_web/blob/master/assignments/week05/athome/assignment.txt
Please complete the assignment by noon on Sunday, February 10, 2013.
Date: Feb. 12, 2013
In this class we'll get introduced to arguably the most popular full-stack Python web framework, Django. We'll build a simple application that introduces us to the basics of Models, Views and Templates. We'll also learn about the Django admin and how it can help us rapidly develop effective applications.
We'll cover basic relational modeling and talk about how to create effective database schemas to model real-world problems. We'll take a look at how the Django ORM (and ORMs in general) can help shield Python developers from SQL.
For our homework, we'll take a look at a set of specifications for a project and create a set of Django Models that will fulfill the specification.
- Django at a Glance - introduction to the concepts and execution of Django
- Quick Install Guide - lightweight instructions on installing Django. Use Python 2.6, not 2.5.
- Django Tutorial, part 1 - as noted below, please actually follow the steps in the tutorial up until you reach Creating Models
- Install Django 1.4.3. Use a Virtualenv and pip or easy_install. (see the installation quick-start above, and the more in-depth guide below)
- Install an RDBMS (I personally recommend PostgreSQL, but MySQL or any other will do. We can even live with sqlite3, so long as you understand it is not for production)
- Set up a Django project. Walk through the first part of the tutorial above until you reach Creating Models. Do Not create models)
- Using Django - far more in-depth information about core topics in Django. Pay particular attention to the installation documentation here.
- Django Design Philosophies - some well-considered words on why Django is the way it is.
You can read the assignment at
http://github.com/cewing/training.python_web/blob/master/assignments/week06/athome/assignment.txt
Please complete the assignment by noon on Sunday, February 17, 2013.
Date: Feb. 19, 2013
In this class we'll dive a bit further into Django. We'll start with a duplicate of the micro-blog we built in week 5 and work in teams to extend the functionality by integrating existing apps. Along the way, we'll have a chance to explore team-based development workflow.
Finally, we'll discuss some of the strengths and weaknesses of Django. What makes it a good choice for some projects but not for others.
Our assignment for the week will be to prepare for working with Pyramid in Week 8.
- Using Django - far more
in-depth information about core topics in Django. Pay attention specifically
to the following topics (you'll want to follow links in these documents):
- Models - details of the django modelling system. How to represent data for, relationships between and the presentation of your objects.
- Queries - basic information about the Django ORM and how to use it to create, retrieve, update and delete objects.
- Working with Forms - how to create, display, and process forms in Django, including forms that are associated with a given model.
- The Django Template Language - learn template basics like variables, filters, tags and blocks, and learn about template inheritance.
- Class-based Generic Views - an introduction to the simplest way to present your objects to your adoring public.
- Testing Django Applications - learn different approaches to testing Django applications, including unit testing and doctests.
- SQLAlchemy and You - A really in-depth look at the differences between the Django ORM and the reigning king of Python database integration, SQLAlchemy.
- About Django from the Pyramid Guy - a talk given at DjangoCon 2012 by Chris McDonough, one of the driving forces behind the Pyramid framework. Also available in video form.
This week we will have no code assignment. Instead the assignment will be to install Pyramid and the ZODB.
WARNING: the ZODB is built with C-based extensions. Installing it requires a c compiler. On linux, gcc will do nicely but you'll need to install python development headers. If you are using Mac OS X, you'll need to install XCode. This is not fast. Be sure to start early in the week to leave time for this.
Read the Instructions
Date: Feb. 26, 2013
This week we will look at a relative newcomer to the Python Web Framework scene, Pyramid. Although the framework is a newcomer, it is represents a combination of several projects, notably Repoze and Pylons, that have been around for quite some time. In fact, the roots of Repoze go back to Zope, the original Python web framework (and quite possibly the first web framework in any language).
We will talk a bit about what makes Pyramid different from other web frameworks. We will look at the specific problems that the creators of Pyramid are looking to solve, and we will investigate how those decisions have influenced the design of the framework.
We'll specifically look at two technologies that set the Pyramid framework apart: the ZODB and URL Traversal. We'll do this by implementing a wiki using these technologies and then discuss what might make such tools appealing to a certain type of project.
We'll also look at a very different templating system, Chameleon, which grew out of Zope Page Templates and the Template Attribute Language. Chameleon provides code structures via XML namespaces, allowing you to write templates that will load in a browser looking like HTML without needing a framework to render them.
Why you should care about Traversal.
Compare and contrast forms of dispatch in Pyramid:
Learn a bit about the ZODB
- Read the tutorial for a quick overview of usage (don't actually do it, though).
- Read the more complete walk-through here altough, again, do not actually do the code examples.
- Learn about object references in the ZODB - one of its greatest strengths.
Learn a bit about the Chameleon ZPT templating language:
In particular, pay attention to:
- The ZODB Book - A work in progress by Carlos De La Guardia.
- The ZPT Appendix to the Zope Book
- Read Defending Pyramid's Design - an excellent point-by-point explanation of the design decisions that went into creating this framework.
Begin work on your final project. You must communicate your plan with Dan and I first to ensure it is of an appropriate scope. If you are having trouble getting started, let us know.
We will be spending most of the class over the next two weeks working. Be prepared to take advantage of the time with Dan and me by getting started now.
Reread the project specification
Date: Mar. 5, 2013
This week we'll talk a bit about deployment options, and take a quick tour of deploying to one of the many possible cloud solutions.
The lion's share of the class will be devoted to lab time, enabling students to work on their final projects with the help of Dan and Cris
Continue working on your final project.
You will have one more week to complete the project after today's class. Your final version must be up and running live by Friday, March 15 at noon.
Date: Mar. 12, 2013
To Be Decided