Shouldn't that ```else``` be shifted over to within the ```if hasattr(self, 'context') and 'request' in self.context:``` if block then?