The first order of business is to add a Cancel button to the last page in the web flow described earlier. We add this to the /path/to/repo/www/chapter_05/templates/purchase.html HTML template:
<form action="/chapter_05/purchase.py" method="post">
<input type="submit" name="cancel" value="Cancel" /></form>
We then modify purchase.py to scan for this extra input in the form post data. The main changes involve changing the message inserts to account for a cancellation. We also scan for the presence of cancel in the form:
if cust :
html_out.addInsert('%name%', cust.getFullName())
lastPurch = purch_service.fetchLastPurchaseForCust(cust.getKey())
if not lastPurch :
html_out.addInsert('%purchase%', 'No recent purchase found')
else :
mostRecent = html_out.buildLastPurchase(lastPurch)
html_out.addInsert...