diff options
Diffstat (limited to 'accounts/models.py')
-rw-r--r-- | accounts/models.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/accounts/models.py b/accounts/models.py index 421b392..0c7ffdb 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -10,6 +10,7 @@ class Account(UserMixin): An Account represents a complex ldap tree entry for spline users. For each service a spline user can have a different password. """ + _ready = False def __init__(self, uid, mail, services=[], dn=None, password=None): self.uid = uid.encode('utf8') if isinstance(uid, unicode) else uid @@ -21,6 +22,7 @@ class Account(UserMixin): self.attributes = {} self._set_attribute('mail', mail) + self._ready = True def __repr__(self): return "<Account uid=%s>" % self.uid @@ -66,6 +68,12 @@ class Account(UserMixin): raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name)) + def __setattr__(self, name, value): + if self._ready and name not in self.__dict__: + self._set_attribute(name, value) + else: + super(Account, self).__setattr__(name, value) + def get_id(self): """ This is for flask-login. The returned string is saved inside |