""" This module demonstrates how to use regular mod_snake module loading to do access denying. If, in a configuration file the directive 'SnakeAllowAccess off' exists, access will be denied. """ import sys import mod_snake class SnakeEasyBlock: def access_checker(self, dir_config, pvr_config, request_rec): if dir_config and not dir_config["enabled"]: return mod_snake.HTTP_FORBIDDEN else: return mod_snake.DECLINED def create_dir_config(self, path): return { "path" : path, "enabled" : 1 } def cmd_SnakeAllowAccess(self, dir_config, svr_config, on_or_off): dir_config["enabled"] = on_or_off def __init__(self, module): directives = { "SnakeAllowAccess" : (mod_snake.OR_ALL, mod_snake.FLAG, self.cmd_SnakeAllowAccess), } module.add_directives(directives) hooks = { "create_dir_config" : self.create_dir_config, "access_checker" : self.access_checker } for hook in hooks.keys(): module.add_hook(hook, hooks[hook])