Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove request after render because its not pickleable #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions templated_mail/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def __init__(self, request=None, context=None, template_name=None,
if template_name is not None:
self.template_name = template_name

self.render()

def get_context_data(self, **kwargs):
ctx = super(BaseEmailMessage, self).get_context_data(**kwargs)
context = dict(ctx, **self.context)
Expand Down Expand Up @@ -66,17 +68,21 @@ def render(self):
self._process_block(block_node, context)
self._attach_body()

def send(self, to, *args, **kwargs):
self.render()
def send(self, *args, **kwargs):
if len(args) > 0:
self.to = args[0]
elif "to" in kwargs:
self.to = kwargs.pop('to')

self.to = to
self.cc = kwargs.pop('cc', [])
self.bcc = kwargs.pop('bcc', [])
self.reply_to = kwargs.pop('reply_to', [])
self.from_email = kwargs.pop(
'from_email', settings.DEFAULT_FROM_EMAIL
)

if hasattr(self, "request"):
del self.request
super(BaseEmailMessage, self).send(*args, **kwargs)

def _process_block(self, block_node, context):
Expand Down
25 changes: 7 additions & 18 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,23 @@ python_paths = .

[tox]
envlist =
py{27,34,35,36,37}-django111
py{34,35,36,37}-django20
py{35,36,37}-django{21,master}
py{38}-django{31,32}
flake8


[travis:env]
DJANGO =
1.11: django111
2.0: django20
2.1: django21
master: djangomaster
3.1: django31
3.2: django32


[testenv]
passenv = CI TRAVIS TRAVIS_*
basepython =
py27: python2.7
py34: python3.4
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
deps =
django111: django>=1.11,<2.0
django20: django>=2.0,<2.1
django21: django>=2.1,<2.2
djangomaster: git+git://github.com/django/django.git
py27: mock
django31: django>=3.1,<3.2
django32: django>=3.2,<3.3
-rrequirements/test
commands =
py.test --ds=tests.settings --capture=no --cov-report term-missing --cov-report html --cov=templated_mail tests
Expand All @@ -40,4 +29,4 @@ commands =
basepython = python3
skip_install = true
deps = flake8
commands = flake8 .
commands = flake8 .