You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each backend service has a unique implementation that extracts the relevant data as part of their implementation of the parse method. In reality, although each backend is unique, they are all extracting strings from an HTTP request object, and there are some shared rules around how to treat this data - e.g. the various email RFCs.
Proposed solution is to have a set of clean_FOO methods in the base RequestParser class that the the implementation can call that implement these basic rules.
e.g.
importemailclassRequestParser()
defclean_to(self, value):
"""Parse string and return list of (name, <address>) tuples."""returnemail.utils.getaddresses(value)
defparse(self, request):
raiseNotImplementedError(u"Must be implemented by inheriting class.")
# and in the implementationclassMyRequestParser(RequestParser):
defparse(self, request):
to=self.clean_to(request.POST.get('recipient')
[...]
Suggested methods:
clean_sender - parse email address
clean_recipients - parse email addresses
clean_html_message - parse HTML, mark safe,
clean_txt_message - parse text, convert to UTF-8 encoded unicode
clean_subject - parse subject, convert to UTF-8 encoded unicode
clean_cc_recipients - parse email addresses
clean_bcc_recipients - parse email addresses
clean_attachments - handle file type restrictions, max/min sizes etc.
The text was updated successfully, but these errors were encountered:
Each backend service has a unique implementation that extracts the relevant data as part of their implementation of the
parse
method. In reality, although each backend is unique, they are all extracting strings from an HTTP request object, and there are some shared rules around how to treat this data - e.g. the various email RFCs.Proposed solution is to have a set of
clean_FOO
methods in the baseRequestParser
class that the the implementation can call that implement these basic rules.e.g.
Suggested methods:
The text was updated successfully, but these errors were encountered: