diff options
author | Leif Johansson <leifj@sunet.se> | 2012-04-20 10:42:45 +0200 |
---|---|---|
committer | Leif Johansson <leifj@sunet.se> | 2012-04-20 10:42:45 +0200 |
commit | 131f7f2d869d394ac6e942c1135529033f1e0ca2 (patch) | |
tree | 128e490a425be8e9834ffdc216743c306d96c84e /coip/apps/scim/schema.py | |
parent | 241905ce73223ed97b6ac9c62d8250b9659f6e3a (diff) |
scim v0.1newprofiles2
Diffstat (limited to 'coip/apps/scim/schema.py')
-rw-r--r-- | coip/apps/scim/schema.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/coip/apps/scim/schema.py b/coip/apps/scim/schema.py new file mode 100644 index 0000000..5290cd5 --- /dev/null +++ b/coip/apps/scim/schema.py @@ -0,0 +1,57 @@ +''' +Created on Apr 12, 2012 + +@author: leifj +''' +from coip.apps.scim import NotAvailable + +class ScimAttribute(object): + def __get__(self,o,objtype=None): + raise NotAvailable() + + def __set__(self,o,v): + raise NotAvailable() + + def __delete__(self,o): + raise NotAvailable() + + def add(self,o,v): + raise NotAvailable() + + def remove(self,o,v): + raise NotAvailable() + +class scim_simple_attribute(ScimAttribute): + + def __init__(self,attr): + self._attr = attr + + def __get__(self,o,objtype=None): + a = getattr(o,self._attr) + if hasattr(a,'__call__'): + return "%s" % a() + else: + return "%s" % a + + def __set__(self,o,v): + a = getattr(o,self._attr) + if hasattr(a,'__call__'): + a(v) + else: + setattr(o,self._attr,v) + + def __delete__(self,o): + a = getattr(o,self._attr) + if not hasattr(a,'__call__'): + setattr(o,self._attr,None) + +class scim_reference_attribute(ScimAttribute): + def __init__(self,attr): + self._attr = attr + + def __get__(self,o,objtype=None): + a = getattr(o,self._attr) + if a != None: + return a.uuid + else: + return None
\ No newline at end of file |