<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_ip(self):
 """ Check ip if that is needed. Raise web.HTTPUnauthorized for not allowed hosts. """

        if self.request.app.get('_check_ip', False):
            ip_address, accept = self.check_ip()
            if not accept:
                raise web.HTTPUnauthorized()