When a customer wishes to make a purchase on the Sweets Complete website, they need to log in. For the purposes of this chapter, we'll present a very simple login system that accepts a username and password from an HTML form and verifies it against the customer's collection.
In Chapter 7, Advanced MongoDB Database Design, you'll learn how to tie MongoDB to Django and use Django's built-in authentication system with MongoDB as the authentication source.
We will start with a Python script called /path/to/repo/www/chapter_05/index.py that's designed to run via the CGI process. This script creates an instance of our customer domain service and uses the web.auth.Authenticate class described earlier in this section. The very first line is extremely important when running Python via CGI. It allows the web server to pass off processing to the currently installed version of Python.
You'll notice that we tell Python where...