from trac.util import TracErrorfrom trac.perm import PermissionErroraction_map = {'allow': True, 'deny': False}def execute(hdf, args, env): """Macro API entry point Initialise and handle a WikiPermissionController. Returns the Controller debug info. """ args = [a.strip() for a in args.split(',')] if len(args) < 2: raise TracError, 'Permission macro expects at least 2 arguments' allow = action_map.get(args[0]) if allow is None: raise TracError, "The first argument to Permission must be 'allow' or 'deny'" username = hdf.getValue('trac.authname', 'anonymous') user_in_list = username in args[1:] if allow != user_in_list: raise PermissionError, 'Denied by Permission macro' return ''