Skip to content

Commit

Permalink
rename payload as content
Browse files Browse the repository at this point in the history
  • Loading branch information
anandology committed Mar 10, 2010
1 parent 3d8e886 commit 2194072
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion web/debugerror.py
Expand Up @@ -332,7 +332,7 @@ def emailerrors_internal():
"bug: %(error_name)s: %(error_value)s (%(path)s)" % locals(),
message,
attachments=[
dict(filename="bug.html", payload=safestr(djangoerror()))
dict(filename="bug.html", content=safestr(djangoerror()))
],
)
return error
Expand Down
12 changes: 6 additions & 6 deletions web/utils.py
Expand Up @@ -1254,8 +1254,8 @@ def sendmail(from_address, to_address, subject, message, headers=None, **kw):
`headers.
Optionally cc, bcc and attachments can be specified as keyword arguments.
Attachments must be a list and each attachment can be either a file object
or a dictionary with filename, payload and optionally content_type keys.
Attachments must be an iterable and each attachment can be either a file object
or a dictionary with filename, content and optionally content_type keys.
If `web.config.smtp_server` is set, it will send the message
to that SMTP server. Otherwise it will look for
Expand All @@ -1266,7 +1266,7 @@ def sendmail(from_address, to_address, subject, message, headers=None, **kw):

for a in attachments or []:
if isinstance(a, dict):
mail.attach(a['filename'], a['payload'], a.get('content_type'))
mail.attach(a['filename'], a['content'], a.get('content_type'))
elif hasattr(a, 'read'): # file
filename = getattr(a, "name", "")
content_type = getattr(a, 'content_type', None)
Expand Down Expand Up @@ -1321,11 +1321,11 @@ def new_message(self):

return Message()

def attach(self, filename, payload, content_type=None):
def attach(self, filename, content, content_type=None):
if not self.multipart:
msg = self.new_message()
msg.add_header("Content-Type", "multipart/mixed")
msg.attach(self.message)
msg.attach(self.message)
self.message = msg
self.multipart = True

Expand All @@ -1338,7 +1338,7 @@ def attach(self, filename, payload, content_type=None):
content_type = content_type or mimetypes.guess_type(filename)[0] or "applcation/octet-stream"

msg = self.new_message()
msg.set_payload(payload)
msg.set_payload(content)
msg.add_header('Content-Type', content_type)
msg.add_header('Content-Disposition', 'attachment', filename=filename)

Expand Down

0 comments on commit 2194072

Please sign in to comment.