Fixed up sample code for the extension hooks.

Issues were found in the example code while going through extension hooks
documentation. If those pieces of example code were ever run they would cause
an error.

Now, all issues have been fixed, and the example code is valid python.

Testing Done:
Ran example code from extension hooks documentation.

Reviewed at https://reviews.reviewboard.org/r/6705/