Deleted and recreated the DB to test for a bug.
This bug causes OpenID collisions as we have not given unique nicknames to users that register at the microblog.
sqlalchemy will throw an error stating that we tried to insert a duplicated nickname in the DB.
We work on dressing up our error pages (if we remove debug=True the user will see a plain 500 internal server error page) and also have errors reported to us.
Added a test script runp.py.
Here we set debug=False to see how the user will get an Internal Server Error 500.
I changed the nickname of two of my OpenID accounts to 'dup' and got the error.
Changed app/views.py to include error handling functions for HTTP 500 and 404.
In the 500 error handler, we make a call to db.session.rollback() because we do not want the DB to end up in an invalid state.
Added templates for HTTP 404 and 500.
Each of them reuses the base template, leaving the feel of the application untouched.
Added mail server settings to config.py.
This is to get the server to report errors faced by users to us.
Added STMPHandler to app/__init__.py.
Changed mailserver to guerrillamail to test.
Flask uses Python's logging module.
Added a RotatingFileHandler to log messages to a file.
It has been chosen to preserve space (at 1MB per file) and use the last ten log files as backups.
logging.Formatter allows us to custom-format our messages.
We lower the logging level both in the app logger and the file logger handler, so as to write useful messages to the log without calling them errors.
Bug Fix Part I.
After the user has logged in, the nickname is generated by the server.
At this point, the server needs to check whether it already has this nickname in the DB. If it does, it needs to return a unique nickname. If not, the nickname generated by splicing the email ID is fine.
The uniqueness is maintained by adding a counter to the nickname and checking the DB if this nickname exists. Eventually we get a unique nick.
Bug Fix Part II.
Added a validate method to the EditForm class. The user enters the nickname of their choice here.
By using an original_nickname argument, we can check whether the nickname has actually changed. If it hasn't, it is accepted. If it has, the DB is checked for whether the new nick exists already. If it does, an error is logged.
Added a g.user.nickname argument to the EditForm constructor in app/views.py.
This reflects the changes made in earlier commits.
Added a test file to test some stuff.
Uses the Pytest testing tool. A setup and teardown function have been defined in the classic xUnit-style.
The first test function verifies that the Gravatar URLs are generated correctly. The avatar is hardcoded into the test and checked against the one returned by User.
The second test verifies that the make_unique_nickname indeed is working properly.
Committing version 3 of the DB.
Modified the config.py file to test email server settings.
Still haven't gotten it working, might want to go the Python mailserver route later.
Merge pull request #5 from VaticanCameos/ch7

Adding chapter 7