Source code for wheezy.security.principal
""" ``principal`` module.
"""
class Principal(object):
[docs] """ Container of user specific security information
"""
def __init__(self, id='', roles=(), alias='', extra=''):
self.id = id
self.roles = roles
self.alias = alias
self.extra = extra
def dump(self):
[docs] """ Dump principal object.
"""
return '\x1f'.join([
self.id,
';'.join(self.roles),
self.alias,
self.extra])
@classmethod
def load(cls, s):
[docs] """ Load principal object from string.
"""
id, roles, alias, extra = s.split('\x1f', 3)
return cls(id, tuple(roles.split(';')), alias, extra)