from turbogears import identity # the identity model class Visit(object): """ A visit to your site """ def lookup_visit(cls, visit_key): return cls.query.get(visit_key) lookup_visit = classmethod(lookup_visit) class VisitIdentity(object): """ A Visit that is link to a User object """ pass class Group(object): """ An ultra-simple group definition. """ pass class User(object): """ Reasonably basic User definition. Probably would want additional attributes. """ def permissions(self): perms = set() for g in self.groups: perms |= set(g.permissions) return perms permissions = property(permissions) def by_email_address(cls, email): """ A class method that can be used to search users based on their email addresses since it is unique. """ return cls.query.filter_by(email_address=email).first() by_email_address = classmethod(by_email_address) def by_user_name(cls, username): """ A class method that permits to search users based on their user_name attribute. """ return cls.query.filter_by(user_name=username).first() by_user_name = classmethod(by_user_name) def _set_password(self, password): """ encrypts password on the fly using the encryption algo defined in the configuration """ self._password = identity.encrypt_password(password) def _get_password(self): """ returns password """ return self._password password = property(_get_password, _set_password) class Permission(object): """ A relationship that determines what each Group can do """ pass