''' 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