Fix getting attribute from local thread.

When using thread-locals, we have to check whether the attribute of the thread local is set before using it.
Todo so always use hasattr or getattr.
Just do:
```
hasattr(edxmako.middleware.REQUEST_CONTEXT, "context"):
  del edxmako.middleware.REQUEST_CONTEXT.context
```

And I don't think we need the first three lines.