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

Jinja email templates #113

Merged
merged 21 commits into from
Aug 3, 2014
Merged

Jinja email templates #113

merged 21 commits into from
Aug 3, 2014

Conversation

erinzm
Copy link
Contributor

@erinzm erinzm commented Jul 17, 2014

Addresses #109. @brad does this look OK?

@erinzm
Copy link
Contributor Author

erinzm commented Jul 17, 2014

Oh, wait, I haven't added the new templates yet. Better do that :)

@erinzm
Copy link
Contributor Author

erinzm commented Jul 17, 2014

Yep, fixed those.

@brad
Copy link
Member

brad commented Jul 17, 2014

The code looks good to me on the service, but have you tested it? It looks like it's causing 500 errors, judging by the test results.

@erinzm
Copy link
Contributor Author

erinzm commented Jul 17, 2014

How would it cause 500s, unless Jinja's doing something bad?
BTW why isn't the whole email-sending thing wrapped in a try...catch?
On Jul 17, 2014 12:53 PM, "Brad Pitcher" notifications@github.com wrote:

The code looks good to me on the service, but have you tested it? It looks
like it's causing 500 errors, judging by the test results.


Reply to this email directly or view it on GitHub
#113 (comment)
.

@brad
Copy link
Member

brad commented Jul 18, 2014

I'm going to review this locally.

@brad
Copy link
Member

brad commented Jul 18, 2014

Looks like it's throwing up due to non-ascii characters in the email:

>> ERROR    2014-07-18 03:31:15,530 webapp2.py:1528] 'ascii' codec can't decode byte 0xe2 in position 760: ordinal not in range(128)
>> Traceback (most recent call last):
>> File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1511, in __call__
>>     rv = self.handle_exception(request, response, e)
>>   File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1505, in __call__
>>     rv = self.router.dispatch(request, response)
>>   File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
>>     return route.handler_adapter(request, response)
>>   File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1077, in __call__
>>     return handler.dispatch()
>>   File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 547, in dispatch
>>     return self.handle_exception(e, self.app.debug)
>>   File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 545, in dispatch
>>     return method(*args, **kwargs)
>> File "/home/brad/projects/mayday/pledgeservice/build/handlers.py", line 291, in post
>>     id, auth_token, receipt_url = pledge_helper(self, data, stripe_customer_id, stripe_charge_id, None, None)
>>   File "/home/brad/projects/mayday/pledgeservice/build/handlers.py", line 208, in pledge_helper
>>     text_template = jinja2.Template(open('email/thank-you.txt').read())
>>   File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 831, in __new__
>>     return env.from_string(source, template_class=cls)
>> File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 769, in from_string
>>     return cls.from_code(self, self.compile(source), globals, None)
>>   File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 479, in compile
>>     source = self._parse(source, name, filename)
>> File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 398, in _parse
>>     return Parser(self, source, name, _encode_filename(filename)).parse()
>>   File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/parser.py", line 32, in __init__
>>     self.stream = environment._tokenize(source, name, filename, state)
>> File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 429, in _tokenize
>>     source = self.preprocess(source, name, filename)
>>   File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 423, in preprocess
>>     self.iter_extensions(), unicode(source))
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 760: ordinal not in range(128)
>> INFO     2014-07-18 03:31:15,539 module.py:612] default: "POST /r/pledge HTTP/1.1" 500 228

I fear that if we had this stuff wrapped in a try/catch we may not have seen this error 😉

@erinzm
Copy link
Contributor Author

erinzm commented Jul 18, 2014

This is probably good to know 😉
On Jul 17, 2014 10:34 PM, "Brad Pitcher" notifications@github.com wrote:

Looks like it's throwing up due to non-ascii characters in the email:

ERROR 2014-07-18 03:31:15,530 webapp2.py:1528] 'ascii' codec can't decode byte 0xe2 in position 760: ordinal not in range(128)
Traceback (most recent call last):
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1511, in call
rv = self.handle_exception(request, response, e)
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1505, in call
rv = self.router.dispatch(request, response)
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1077, in call
return handler.dispatch()
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(_args, *_kwargs)
File "/home/brad/projects/mayday/pledgeservice/build/handlers.py", line 291, in post
id, auth_token, receipt_url = pledge_helper(self, data, stripe_customer_id, stripe_charge_id, None, None)
File "/home/brad/projects/mayday/pledgeservice/build/handlers.py", line 208, in pledge_helper
text_template = jinja2.Template(open('email/thank-you.txt').read())
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 831, in new
return env.from_string(source, template_class=cls)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 769, in from_string
return cls.from_code(self, self.compile(source), globals, None)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 479, in compile
source = self._parse(source, name, filename)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 398, in _parse
return Parser(self, source, name, _encode_filename(filename)).parse()
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/parser.py", line 32, in init
self.stream = environment._tokenize(source, name, filename, state)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 429, in _tokenize
source = self.preprocess(source, name, filename)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 423, in preprocess
self.iter_extensions(), unicode(source))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 760: ordinal not in range(128)
INFO 2014-07-18 03:31:15,539 module.py:612] default: "POST /r/pledge HTTP/1.1" 500 228

I fear that if we had this stuff wrapped in a try/catch we may not have
seen this error [image: 😉]


Reply to this email directly or view it on GitHub
#113 (comment)
.

@erinzm
Copy link
Contributor Author

erinzm commented Jul 18, 2014

Hmm, looks like I have to just unicodify the template sources and then wrap
the variables in unicode(..., "utf-8").

On Thu, Jul 17, 2014 at 10:42 PM, L. Mars shakespeares.integral@gmail.com
wrote:

This is probably good to know 😉
On Jul 17, 2014 10:34 PM, "Brad Pitcher" notifications@github.com wrote:

Looks like it's throwing up due to non-ascii characters in the email:

ERROR 2014-07-18 03:31:15,530 webapp2.py:1528] 'ascii' codec can't decode byte 0xe2 in position 760: ordinal not in range(128)
Traceback (most recent call last):
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1511, in call
rv = self.handle_exception(request, response, e)
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1505, in call
rv = self.router.dispatch(request, response)
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 1077, in call
return handler.dispatch()
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/opt/google-appengine-python/lib/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(_args, *_kwargs)
File "/home/brad/projects/mayday/pledgeservice/build/handlers.py", line 291, in post
id, auth_token, receipt_url = pledge_helper(self, data, stripe_customer_id, stripe_charge_id, None, None)
File "/home/brad/projects/mayday/pledgeservice/build/handlers.py", line 208, in pledge_helper
text_template = jinja2.Template(open('email/thank-you.txt').read())
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 831, in new
return env.from_string(source, template_class=cls)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 769, in from_string
return cls.from_code(self, self.compile(source), globals, None)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 479, in compile
source = self._parse(source, name, filename)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 398, in _parse
return Parser(self, source, name, _encode_filename(filename)).parse()
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/parser.py", line 32, in init
self.stream = environment._tokenize(source, name, filename, state)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 429, in _tokenize
source = self.preprocess(source, name, filename)
File "/opt/google-appengine-python/lib/jinja2-2.6/jinja2/environment.py", line 423, in preprocess
self.iter_extensions(), unicode(source))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 760: ordinal not in range(128)
INFO 2014-07-18 03:31:15,539 module.py:612] default: "POST /r/pledge HTTP/1.1" 500 228

I fear that if we had this stuff wrapped in a try/catch we may not have
seen this error [image: 😉]


Reply to this email directly or view it on GitHub
#113 (comment)
.

@erinzm
Copy link
Contributor Author

erinzm commented Jul 18, 2014

@brad Tests aren't passing but it works locally.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) when pulling 1fc179e on ArchimedesPi:jinja-email-templates into 97b556a on MayOneUS:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) when pulling 1fc179e on ArchimedesPi:jinja-email-templates into 97b556a on MayOneUS:master.

@erinzm
Copy link
Contributor Author

erinzm commented Jul 18, 2014

@brad Travis says it's OK, it works OK locally. Can we pull and deploy to dev to test?

@erinzm
Copy link
Contributor Author

erinzm commented Jul 18, 2014

Added Unicode on email to be sent to.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) when pulling 2a89988 on ArchimedesPi:jinja-email-templates into 97b556a on MayOneUS:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) when pulling 738fa10 on ArchimedesPi:jinja-email-templates into 97b556a on MayOneUS:master.

@erinzm
Copy link
Contributor Author

erinzm commented Jul 18, 2014

@brad 4ed136a blew up a bunch of stuff: apparently a lot of functions can't handle Unicode strings.

@erinzm
Copy link
Contributor Author

erinzm commented Jul 20, 2014

Thanks for the PR @brad

@coveralls
Copy link

Coverage Status

Coverage increased (+0.46%) when pulling 674fa9a on ArchimedesPi:jinja-email-templates into 97b556a on MayOneUS:master.

@brad
Copy link
Member

brad commented Jul 20, 2014

No problem, I think maybe we should just do a .encode('utf-8') on the email and name. That's how it was before, except only for the name. I think what that does is convert the unicode code into the actually nice looking character, e.g. converting \u00E1 to á

@erinzm
Copy link
Contributor Author

erinzm commented Jul 23, 2014

Is this merge-able yet @brad?

@erinzm
Copy link
Contributor Author

erinzm commented Jul 25, 2014

Does this look OK @jwhite66?

@brad
Copy link
Member

brad commented Jul 25, 2014

@ArchimedesPi My last comment hasn't been addressed yet. This is probably fine as is though.

@jwhite66
Copy link
Contributor

I'm a little concerned that there is enough being changed in this, that it should get careful review and a careful test. I'd like to get our current effort on addresses done, and then maybe get this code live on dev for some testing and more review. (And it'd be nice to get this in so we can stop bugging Mailchimp every few minutes; our task queues are full of bad emails being subscribed over and over again :-( ).

@erinzm
Copy link
Contributor Author

erinzm commented Jul 25, 2014

I want to know if my rebased branch tests OK, but Travis is having problems.
:frown:
On Jul 24, 2014 11:32 PM, "Jeremy White" notifications@github.com wrote:

I'm a little concerned that there is enough being changed in this, that it
should get careful review and a careful test. I'd like to get our current
effort on addresses done, and then maybe get this code live on dev for some
testing and more review. (And it'd be nice to get this in so we can stop
bugging Mailchimp every few minutes; our task queues are full of bad emails
being subscribed over and over again :-( ).


Reply to this email directly or view it on GitHub
#113 (comment)
.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.44%) when pulling 0ec7c62 on ArchimedesPi:jinja-email-templates into f11a18a on MayOneUS:master.

@erinzm
Copy link
Contributor Author

erinzm commented Jul 25, 2014

Thanks @brad, after rebasing against upstream/master I broke my history vs the PR's :(
Your PR fixes it, so now I can rest assured that tests will pass :)

@brad
Copy link
Member

brad commented Jul 25, 2014

No problem. I love to see Travis happy :neckbeard:

@erinzm
Copy link
Contributor Author

erinzm commented Jul 31, 2014

Hey @brad, is this pushed to pledgedev?

@brad
Copy link
Member

brad commented Aug 1, 2014

Don't think so, @jwhite66 has a way to specify a specific branch on pledgedev.

@erinzm
Copy link
Contributor Author

erinzm commented Aug 1, 2014

Hey @aaronlifshin, can I test this out on pledgedev?

aaronlifshin added a commit that referenced this pull request Aug 3, 2014
@aaronlifshin aaronlifshin merged commit 26c98c7 into MayOneUS:master Aug 3, 2014
@aaronlifshin
Copy link
Member

Pushed to pledgedev.

Please test it quickly, as it is now in the main branch.

A

On Fri, Aug 1, 2014 at 9:03 AM, Liam M notifications@github.com wrote:

Hey @aaronlifshin https://github.com/aaronlifshin, can I test this out
on pledgedev?


Reply to this email directly or view it on GitHub
#113 (comment)
.

@erinzm
Copy link
Contributor Author

erinzm commented Aug 4, 2014

Testing...

@erinzm
Copy link
Contributor Author

erinzm commented Aug 4, 2014

@aaronlifshin It "works", but it looks like this. Should it look like this?

screenshot from 2014-08-03 20 42 48

@erinzm
Copy link
Contributor Author

erinzm commented Aug 4, 2014

I think it stripped the newlines. Any ideas @brad?

@aaronlifshin
Copy link
Member

No.

It should not look like that. Please fix it or roll it back.

A

On Sun, Aug 3, 2014 at 6:44 PM, Liam M notifications@github.com wrote:

@aaronlifshin https://github.com/aaronlifshin It "works", but it looks
like this. Should it look like this?

[image: screenshot from 2014-08-03 20 42 48]
https://cloud.githubusercontent.com/assets/4635721/3792467/c9ec1d12-1b78-11e4-84ff-089498e8bddc.png


Reply to this email directly or view it on GitHub
#113 (comment)
.

@erinzm
Copy link
Contributor Author

erinzm commented Aug 4, 2014

OK, looks like the newlines are wonky. Recreating the newlines in the
template files should work. But it's weird, the tests all pass.
On Aug 3, 2014 8:47 PM, "aaronlifshin" notifications@github.com wrote:

No.

It should not look like that. Please fix it or roll it back.

A

On Sun, Aug 3, 2014 at 6:44 PM, Liam M notifications@github.com wrote:

@aaronlifshin https://github.com/aaronlifshin It "works", but it
looks
like this. Should it look like this?

[image: screenshot from 2014-08-03 20 42 48]
<
https://cloud.githubusercontent.com/assets/4635721/3792467/c9ec1d12-1b78-11e4-84ff-089498e8bddc.png>


Reply to this email directly or view it on GitHub
<
https://github.com/MayOneUS/pledgeservice/pull/113#issuecomment-51010556>
.


Reply to this email directly or view it on GitHub
#113 (comment)
.

@aaronlifshin
Copy link
Member

@ArchimedesPi this one was an extremely frustrating pull request. Now it's blocking priority work, and I have to fix and re-test the issues your changes have created.

@erinzm
Copy link
Contributor Author

erinzm commented Aug 4, 2014

Sorry. Github has a "revert PR" button, you can use that to revert it.

On Mon, Aug 4, 2014 at 11:10 AM, aaronlifshin notifications@github.com
wrote:

@ArchimedesPi https://github.com/ArchimedesPi this one was an extremely
frustrating pull request. Now it's blocking priority work, and I have to
fix and re-test the issues your changes have created.


Reply to this email directly or view it on GitHub
#113 (comment)
.

@aaronlifshin
Copy link
Member

I did.

On Mon, Aug 4, 2014 at 11:51 AM, Liam M notifications@github.com wrote:

Sorry. Github has a "revert PR" button, you can use that to revert it.

On Mon, Aug 4, 2014 at 11:10 AM, aaronlifshin notifications@github.com
wrote:

@ArchimedesPi https://github.com/ArchimedesPi this one was an
extremely
frustrating pull request. Now it's blocking priority work, and I have to
fix and re-test the issues your changes have created.


Reply to this email directly or view it on GitHub
<
https://github.com/MayOneUS/pledgeservice/pull/113#issuecomment-51080771>
.


Reply to this email directly or view it on GitHub
#113 (comment)
.

@aaronlifshin
Copy link
Member

No biggie, just reverted it.

On Mon, Aug 4, 2014 at 11:52 AM, Liam M notifications@github.com wrote:

I feel like I'm constantly annoying you :(

On Mon, Aug 4, 2014 at 1:51 PM, aaronlifshin notifications@github.com
wrote:

I did.

On Mon, Aug 4, 2014 at 11:51 AM, Liam M notifications@github.com
wrote:

Sorry. Github has a "revert PR" button, you can use that to revert it.

On Mon, Aug 4, 2014 at 11:10 AM, aaronlifshin <
notifications@github.com>

wrote:

@ArchimedesPi https://github.com/ArchimedesPi this one was an
extremely
frustrating pull request. Now it's blocking priority work, and I
have
to
fix and re-test the issues your changes have created.


Reply to this email directly or view it on GitHub
<

https://github.com/MayOneUS/pledgeservice/pull/113#issuecomment-51080771>

.


Reply to this email directly or view it on GitHub
<
https://github.com/MayOneUS/pledgeservice/pull/113#issuecomment-51101157>

.


Reply to this email directly or view it on GitHub
<
https://github.com/MayOneUS/pledgeservice/pull/113#issuecomment-51101202>
.


Reply to this email directly or view it on GitHub
#113 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants