Skip to content

Commit eee2a03

Browse files
agjohnsonericholscher
authored andcommitted
Fix problem with context data on password reset email (#2455)
Allauth sent context that wasn't able to serialize with pickle when passing to Celery. Remove the data, as it wasn't even needed anyways. Fixes #2442
1 parent 322140f commit eee2a03

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

readthedocs/core/adapters.py

+18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"""Allauth overrides"""
22

3+
import pickle
4+
import logging
5+
36
from allauth.account.adapter import DefaultAccountAdapter
47
from django.template.loader import render_to_string
58

@@ -10,6 +13,8 @@
1013
except ImportError:
1114
from django.utils.encoding import force_unicode as force_text
1215

16+
log = logging.getLogger(__name__)
17+
1318

1419
class AccountAdapter(DefaultAccountAdapter):
1520

@@ -25,6 +30,19 @@ def send_mail(self, template_prefix, email, context):
2530
subject = " ".join(subject.splitlines()).strip()
2631
subject = self.format_email_subject(subject)
2732

33+
# Allauth sends some additional data in the context, remove it if the
34+
# pieces can't be pickled
35+
removed_keys = []
36+
for key in context.keys():
37+
try:
38+
_ = pickle.dumps(context[key])
39+
except pickle.PickleError:
40+
removed_keys.append(key)
41+
del context[key]
42+
if removed_keys:
43+
log.debug('Removed context we were unable to serialize: %s',
44+
removed_keys)
45+
2846
send_email(
2947
recipient=email,
3048
subject=subject,

0 commit comments

Comments
 (0)