From dc67b6b87cb59d4082663a53102e00c5dd57262a Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 24 May 2012 21:44:07 +0200 Subject: [PATCH] Added a lock funcion self(), passing only if accessing_obj == accessed_obj. This is potentially useful for Objects who want to lock cmdsets and make them only available to themselves without having to know their id value in the lockstring. --- src/locks/lockfuncs.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/locks/lockfuncs.py b/src/locks/lockfuncs.py index 73844aaab5..d16081a0e7 100644 --- a/src/locks/lockfuncs.py +++ b/src/locks/lockfuncs.py @@ -107,6 +107,19 @@ def false(*args, **kwargs): def none(*args, **kwargs): return False +def self(accessing_obj, accessed_obj, *args, **kwargs): + """ + Check if accessing_obj is the same as accessed_obj + + Usage: + self() + + This can be used to lock specifically only to + the same object that the lock is defined on. + """ + return accessing_obj == accessed_obj + + def perm(accessing_obj, accessed_obj, *args, **kwargs): """ The basic permission-checker. Ignores case.