We can now turn our attention to the web script that processes purchases: /path/to/repo/www/chapter_06/purchase.py. This script was first introduced in Chapter 5, Mission-Critical MongoDB Database Tasks. As with the modified select.py script, described in the previous section of this chapter, we use the new Config service, as well as having moved the responder class, as shown:
from web.responder.html import HtmlResponder
html_out = HtmlResponder('templates/purchase.html')
The main difference in this version is how a list of the products purchased is built. As before, we initialize an empty dictionary, productsPurchased. We then add a dictionary obtained from the products domain service that contains product keys:
prodKeys = prod_service.fetchKeys()
productsPurchased = dict()
We loop through the list of product keys and recreate the quantity purchased form element name sent to the data table:Â qtyKey = 'qty_...