`if user is not None and user.userid == self.profile.userid ...` or this will fail for not-logged-in users.