~allenap/maas/backup

« back to all changes in this revision

Viewing changes to src/maasserver/middleware.py

  • Committer: Gavin Panella
  • Date: 2012-03-15 13:58:32 UTC
  • mto: This revision was merged to the branch mainline in revision 291.
  • Revision ID: gavin.panella@canonical.com-20120315135832-8i2rkbvp6gwdhkzt
Change MaaS to MAAS everywhere.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    HttpResponseRedirect,
33
33
    )
34
34
from django.utils.http import urlquote_plus
35
 
from maasserver.exceptions import MaaSAPIException
 
35
from maasserver.exceptions import MAASAPIException
36
36
 
37
37
 
38
38
def get_relative_path(path):
53
53
 
54
54
    Most UI views are visible only to logged-in users, but there are pages
55
55
    that are accessible to anonymous users (e.g. the login page!) or that
56
 
    use other authentication (e.g. the MaaS API, which is managed through
 
56
    use other authentication (e.g. the MAAS API, which is managed through
57
57
    piston).
58
58
    """
59
59
 
93
93
class ExceptionMiddleware:
94
94
    """Convert exceptions into appropriate HttpResponse responses.
95
95
 
96
 
    For example, a MaaSAPINotFound exception processed by a middleware
 
96
    For example, a MAASAPINotFound exception processed by a middleware
97
97
    based on this class will result in an http 404 response to the client.
98
98
    Validation errors become "bad request" responses.
99
99
 
122
122
            return None
123
123
 
124
124
        encoding = b'utf-8'
125
 
        if isinstance(exception, MaaSAPIException):
126
 
            # The exception is a MaaSAPIException: exception.api_error
 
125
        if isinstance(exception, MAASAPIException):
 
126
            # The exception is a MAASAPIException: exception.api_error
127
127
            # will give us the proper error type.
128
128
            return HttpResponse(
129
129
                content=unicode(exception).encode(encoding),