from storage import StorableObject

class User(StorableObject):
    _names = 'users'

    name = None
    email = None
    roles = None
    name_identifiers = None
    identification_token = None
    lasso_dump = None
    is_admin = False
    anonymous = False

    def __init__(self, name = None):
        StorableObject.__init__(self)
        self.name = name
        self.name_identifiers = []
        self.roles = []

    def migrate(self):
        changed = False

        if self.roles and 'site-admin' in self.roles:
            self.is_admin = True
            self.roles = [x for x in self.roles if x != 'site-admin']
            changed = True

        if changed:
            self.store()
