<NME> decorators.py
<BEF> ADDFILE
<MSG> wip: Resellers and limits (see #105)

* Added support for migrations
* Big refactoring of the admin code

done: Support for SHA256 algorithm to store passwords (fix #195)
done: admin models refactoring (fix #196)

<DFF> @@ -0,0 +1,22 @@
+# coding: utf-8
+"""
+:mod:`decorators` --- common decorators
+---------------------------------------
+"""
+from functools import wraps
+from exceptions import NeedsMailboxException
+
+def needs_mailbox():
+    """Check if the current user owns at least one mailbox
+
+    Some applications (the webmail for example) need a mailbox to
+    work.
+    """
+    def decorator(f):
+        @wraps(f)
+        def wrapped_f(request, *args, **kwargs):
+            if request.user.has_mailbox:
+                return f(request, *args, **kwargs)
+            raise NeedsMailboxException()
+        return wrapped_f
+    return decorator

wip: Resellers and limits (see #105)