class TG_Group(Unit): group_id = UnitProperty(int) group_name = UnitProperty(unicode, index=True, hints={"bytes": 16}) display_name = UnitProperty(unicode, hints={"bytes": 255}) created = UnitProperty(datetime.datetime) ID = None identifiers = ("group_id", ) sequencer = UnitSequencerInteger() # Old names groupId = DeprecatedAttr("groupId", "group_name") displayName = DeprecatedAttr("displayName", "display_name") def get_users(self): return set([ i[2] for i in self.sandbox.recall( group_class + user_group_class + user_class, lambda g, up, u: g.group_id == self.group_id) ]) users = property(get_users) def get_permissions(self): return set([ i[2] for i in self.sandbox.recall( group_class + group_permission_class + permission_class, lambda g, gp, p: g.group_id == self.group_id) ]) permissions = property(get_permissions)
class TG_Session(Unit): key = UnitProperty(unicode, hints={"bytes": 40}) data = UnitProperty(str, hints={"bytes": 0}) expiration_time = UnitProperty(datetime.datetime, index=True) ID = None identifiers = ("key", ) sequencer = UnitSequencer()
class TG_Visit(Unit): visit_key = UnitProperty(str, index=True, hints={"bytes": 40}) created = UnitProperty(datetime.datetime) expiry = UnitProperty(datetime.datetime) ID = None identifiers = ("visit_key", ) sequencer = UnitSequencer() def lookup_visit(cls, visit_key): box = hub.getConnection() box.start(isolation=turbogears.database.READ_COMMITTED) visit = box.unit(visit_class, visit_key=visit_key) box.flush_all() return visit lookup_visit = classmethod(lookup_visit)
class TG_Permission(Unit): permission_id = UnitProperty(int) permission_name = UnitProperty(unicode, index=True, hints={"bytes": 16}) description = UnitProperty(unicode, hints={"bytes": 255}) ID = None identifiers = ("permission_id", ) sequencer = UnitSequencerInteger() # Old attributes permissionId = DeprecatedAttr("permissionId", "permission_name") def get_groups(self): return set([ i[2] for i in self.sandbox.recall( permission_class + group_permission_class + group_class, lambda p, gp, g: p.permission_id == self.permission_id) ]) groups = property(get_groups)
class TG_User(Unit): user_id = UnitProperty(int) user_name = UnitProperty(unicode, index=True, hints={"bytes": 16}) email_address = UnitProperty(unicode, index=True, hints={"bytes": 255}) display_name = UnitProperty(unicode, hints={"bytes": 255}) password = PasswordProperty(unicode, hints={"bytes": 40}) created = UnitProperty(datetime.datetime) ID = None identifiers = ("user_id", ) sequencer = UnitSequencerInteger() # Old attribute names userId = DeprecatedAttr("userId", "user_name") emailAddress = DeprecatedAttr("emailAddress", "email_address") displayName = DeprecatedAttr("displayName", "display_name") def get_permissions(self): permissions = set() for user, user_group, group, group_permission, permission in self.sandbox.recall( user_class + user_group_class + group_class + group_permission_class + permission_class, lambda u, ug, g, gp, p: u.user_id == self.user_id): permissions = permissions | set([permission]) return permissions permissions = property(get_permissions) def get_groups(self): return set([ i[2] for i in self.sandbox.recall( user_class + user_group_class + group_class, lambda u, ug, g: u.user_id == self.user_id) ]) groups = property(get_groups) def set_password_raw(self, password): "Saves the password as-is to the database." #self._SO_set_password(password) raise NotImplementedError
class TG_GroupPermission(Unit): permission_id = UnitProperty(int) group_id = UnitProperty(int) ID = None identifiers = ("permission_id", "group_id") sequencer = UnitSequencer()
class TG_UserGroup(Unit): user_id = UnitProperty(int) group_id = UnitProperty(int) ID = None identifiers = ("user_id", "group_id") sequencer = UnitSequencer()
class TG_VisitIdentity(Unit): visit_key = UnitProperty(str, hints={"bytes": 40}) user_id = UnitProperty(int) ID = None identifiers = ("visit_key", ) sequencer = UnitSequencer()