'(Lazy) check debug mode and activate the respective settings'

def check_debug(self):

    debug = self._debug
    base_debug = bool(self.get_base_debug())
    if ((debug is None) or (debug != base_debug)):
        self._debug = base_debug
        debug = (base_debug or current.request.get_vars.get('debug', False))
        from gluon.custom_import import track_changes
        s3 = current.response.s3
        if debug:
            s3.debug = True
            track_changes(True)
        else:
            s3.debug = False
            track_changes(False)
