def permission_check(check):
    """
    Class decorator for subclasses of PublicTask to sprinkle in re-usable
    permission checks::

        @permission_check(user_id_matches)
        class MyTask(PublicTask):
            def run_public(self, user_id):
                pass
    """

    def decorator(cls):
        cls.check_permission = staticmethod(check)
        return cls
    return decorator