'Checks a lock of the correct type by passing execution off to
the lock function(s).
Args:
accessing_obj (object): The object seeking access.
access_type (str): The type of access wanted.
default (bool, optional): If no suitable lock type is
found, default to this result.
no_superuser_bypass (bool): Don\'t use this unless you
really, really need to, it makes supersusers susceptible
to the lock check.
Notes:
A lock is executed in the follwoing way:
Parsing the lockstring, we (during cache) extract the valid
lock functions and store their function objects in the right
order along with their args/kwargs. These are now executed in
sequence, creating a list of True/False values. This is put
into the evalstring, which is a string of AND/OR/NOT entries
separated by placeholders where each function result should
go. We just put those results in and evaluate the string to
get a final, combined True/False value for the lockstring.
The important bit with this solution is that the full
lockstring is never blindly evaluated, and thus there (should
be) no way to sneak in malign code in it. Only "safe" lock
functions (as defined by your settings) are executed.'

def check(self, accessing_obj, access_type, default=False, no_superuser_bypass=False):

    try:
        if (accessing_obj.locks.lock_bypass and (not no_superuser_bypass)):
            return True
    except AttributeError:
        if ((not no_superuser_bypass) and ((hasattr(accessing_obj, 'is_superuser') and accessing_obj.is_superuser) or (hasattr(accessing_obj, 'player') and hasattr(accessing_obj.player, 'is_superuser') and accessing_obj.player.is_superuser) or (hasattr(accessing_obj, 'get_player') and ((not accessing_obj.get_player()) or accessing_obj.get_player().is_superuser)))):
            return True
    if (access_type in self.locks):
        (evalstring, func_tup, raw_string) = self.locks[access_type]
        true_false = tuple((bool(tup[0](accessing_obj, self.obj, *tup[1], **tup[2])) for tup in func_tup))
        return eval((evalstring % true_false))
    else:
        return default
