X-Git-Url: http://git.veekun.com/zzz-spline-users.git/blobdiff_plain/4aafbf548ba21c9b8d8d0d7486b428195a4a87ce..563477a59e282678a232bd4cf151736c92c0e238:/splinext/users/model/__init__.py diff --git a/splinext/users/model/__init__.py b/splinext/users/model/__init__.py index 2fd444b..d6c0cb5 100644 --- a/splinext/users/model/__init__.py +++ b/splinext/users/model/__init__.py @@ -9,6 +9,22 @@ from sqlalchemy.types import Integer, Unicode from spline.model.meta import TableBase +class AnonymousUser(object): + """Fake user object, for when the user isn't actually logged in. + + Tests as false and tries to respond to method calls the expected way. + """ + + def __nonzero__(self): + return False + def __bool__(self): + return False + + def can(self, action): + # XXX if viewing is ever a permission, this should probably change. + return False + + class User(TableBase): __tablename__ = 'users' id = Column(Integer, primary_key=True) @@ -24,6 +40,10 @@ class User(TableBase): super(User, self).__init__(*args, **kwargs) + def can(self, action): + # XXX this is probably not desired. + return True + @property def unique_colors(self): """Returns a list of (width, '#rrggbb') tuples that semi-uniquely