summaryrefslogtreecommitdiff
path: root/coip/apps/scim/schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'coip/apps/scim/schema.py')
-rw-r--r--coip/apps/scim/schema.py57
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