def on_close(self): if hasattr(self, 'user'): UserSession.clearUserSession(self) print "on close", self.user