From 7e97811156ad3fbf9daafc253a2c473b05e07542 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sat, 22 Sep 2012 13:35:24 -0400 Subject: * You can now PUT and PATCH on user resources to change the user's display name or password. For passwords, you pass in the clear text password and Mailman will hash it before storing. Also: * Major refactoring of validators for PUT and PATCH. Pull the common logic out of configuration.py and put it in a PatchValidator class in helpers.py. Also move GetterSetter to helpers.py * Add new exception classes RESTError, UnknownPATCHRequestError, ReadOnlyPATCHRequestError. These are used in the PatchValidator. * Added Validator.update() which works nicely for PATCH and PUT. --- src/mailman/core/errors.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/mailman/core/errors.py') diff --git a/src/mailman/core/errors.py b/src/mailman/core/errors.py index 529ac86fe..95a318ca6 100644 --- a/src/mailman/core/errors.py +++ b/src/mailman/core/errors.py @@ -43,7 +43,10 @@ __all__ = [ 'MemberError', 'MustDigestError', 'PasswordError', + 'RESTError', + 'ReadOnlyPATCHRequestError', 'RejectMessage', + 'UnknownPATCHRequestError', ] @@ -126,3 +129,22 @@ class BadPasswordSchemeError(PasswordError): def __str__(self): return 'A bad password scheme was given: %s' % self.scheme_name + + + +class RESTError(MailmanError): + """Base class for REST API errors.""" + + +class UnknownPATCHRequestError(RESTError): + """A PATCH request contained an unknown attribute.""" + + def __init__(self, attribute): + self.attribute = attribute + + +class ReadOnlyPATCHRequestError(RESTError): + """A PATCH request contained a read-only attribute.""" + + def __init__(self, attribute): + self.attribute = attribute -- cgit v1.2.3-70-g09d2