Permalink
Browse files

Removed old example templates, changed __init__ function, so that aut…

…ocompletion in IDE works
  • Loading branch information...
Kevin Renskers
Kevin Renskers committed Dec 1, 2011
1 parent dda8faf commit 4152cc25614163dd4771672bda2f23675a98adff
View
@@ -21,7 +21,7 @@ Sending email should be as easy as creating an instance of the email class, prov
This email class doesn't know about mail queues. You can use a custom email backend or a project like [Django-mailer](https://github.com/jtauber/django-mailer) for that.
## Usage
- from generic_email import Email
+ from generic_mail import Email
# This will send text email only, uses the email/base_text_email.html template with the "body" template variable
email = Email('to@example.com', 'Subject', 'Line one\n\nLine two')
View
@@ -47,15 +47,21 @@ class Email(object):
_custom_templates = False
_markdown = None
- def __init__(self, **kwargs):
+ def __init__(self, to=None, subject=None, text_body=None, html_body=None, attachments=None, cc=None, bcc=None,
+ from_address=None, text_template=None, html_template=None, **kwargs):
"""
Init the class, the kwargs will be used as context variables
"""
- for key in kwargs.copy():
- if hasattr(self, key) and not key.startswith('_'):
- setattr(self, key, kwargs[key])
- del kwargs[key]
-
+ self.to = to or self.to
+ self.subject = subject or self.subject
+ self.attachments = attachments or self.attachments
+ self.cc = cc or self.cc
+ self.bcc = bcc or self.bcc
+ self.from_address = from_address or self.from_address
+ self.text_body = text_body or self.text_body
+ self.html_body = html_body or self.html_body
+ self.text_template = text_template or self.text_template
+ self.html_template = html_template or self.html_template
self.kwargs = kwargs
if self.text_template or self.html_template:
@@ -1,3 +1 @@
-<p>Hello,</p>
{{ body|safe }}
-<p>Goodbye.</p>
@@ -1,5 +1 @@
-Hello,
-
{{ body }}

This comment has been minimized.

Show comment
Hide comment
@hvdklauw

hvdklauw Dec 1, 2011

Contributor

Here you also want a |safe escape.

Reasoning: It's text mail and you don't want any html tags to be escaped, they will be displayed as is.
<strong> vs &lt;strong&gt;

@hvdklauw

hvdklauw Dec 1, 2011

Contributor

Here you also want a |safe escape.

Reasoning: It's text mail and you don't want any html tags to be escaped, they will be displayed as is.
<strong> vs &lt;strong&gt;

This comment has been minimized.

Show comment
Hide comment
@kevinrenskers

kevinrenskers Dec 1, 2011

Owner

Will do

-
-Goodbye.
@@ -1,3 +0,0 @@
-<p>Hello,</p>
-<p>This is email.</p>
-<p>Goodbye.</p>
@@ -1,5 +0,0 @@
-Hello,
-
-This is email.
-
-Goodbye.

0 comments on commit 4152cc2

Please sign in to comment.