Closed Bug 531314 Opened 16 years ago Closed 16 years ago

[weekly-updates] Simplify local development, inline CSS in HTML emails, cleanup text emails

Categories

(Websites :: Other, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: asuth, Assigned: asuth)

Details

Attachments

(1 file)

I have just been doing plain text statuses without HTML markup. This looks okay in the web UI, but my superiors who were using e-mail complained because the newlines got lost and things became a jumble. The initial goal of this patch was to just inline the CSS in the HTML e-mail so that things look the same in e-mail or from the web. Along the way I also: - Fixed an apparent bug in blake's changes where 'app' did not always exist? I'm suspecting you (bsmedberg) fixed this locally and just did not push to your repo... - Added a script to help someone run the program locally with minimal setup. See the README file for slightly more information. - Removed an apparently mooted column from dbschema.sql. - Basically disabled connection pooling for SQLite. I was getting exceptions about SQLite instances not being valid on different threads than they were created on. Given that SQLite is likely only used in development situations, this solution seems sufficient but thread-local connection caching could still be feasible. - Introduced a simple cleanup heuristic for whitespace for text e-mails. I'm not sure how this worked before my changes, but I'm sure my changes made it a worse problem, so this is nice to have. One note is that all the e-mail payloads end up base64 encoded because of the utf-8 charset and the python email module being paranoid about 8-bit safety. This makes it slightly more annoying to debug than it could be.
Attachment #414778 - Flags: review?(benjamin)
Comment on attachment 414778 [details] [diff] [review] local dev support, inline CSS in html emails, cleanup text emails >diff --git a/devtest/dummy-smtpd-server.py b/devtest/dummy-smtpd-server.py >+FILE_PATH = '/tmp/smtpd-received.eml' Can we do something better with this, like write it in the CWD, or use tempfile.mkstemp? I'd like this to work on Windows if possible. >diff --git a/devtest/run b/devtest/run >+#!/bin/sh I'm a little unhappy that this is a shell script, because it means Windows-y folks would have to have a shell. It shouldn't be too hard to do this in python, though (you can do the sed and sqlite stuff directly). >diff --git a/weeklyupdates/mail.py b/weeklyupdates/mail.py >+ htmlBody = t.generate(loginname=None, subject=subject, mode='email', >+ inlineroot=WEB_ROOT, inlinecss=True, **kwargs) >+ textBody = t.generate(loginname=None, subject=subject, mode='email', >+ **kwargs) >+ return htmlBody.render('html'), reduce_whitespace(textBody.render('text')) It feels like it's not necessary to do this in the python; I believe you could specify inlinecss in message.xhtml using a py:with > def getdigest(to, subject, posts): >+ app = cherrypy.request.app I did hard-code a fix for this: this is incorrect because when we're sending the nightly cronjob there is no cherrypy.request and this will throw. >diff --git a/weeklyupdates/model.py b/weeklyupdates/model.py >+ # sqlite has threading constraints, so cripple the connection pool. >+ self.done = lambda db: None Interesting, what are the constraints? As far as I can tell each connection and cursor here is apartment-threaded, which should be safe for sqlite. >diff --git a/weeklyupdates/templates/common.xhtml b/weeklyupdates/templates/common.xhtml >+def inline_file(relpath): >+ # I am unable to find a clean/easy way to find our path, so we require it to >+ # be passed in. >+ path = os.path.join(inlineroot, relpath) >+ f = open(path); >+ data = Markup(f.read()) >+ f.close() >+ return data I don't think this function, nor the inlineroot variable are necessary, see below. >+ <py:choose> >+ <py:when test="value_of('inlinecss')"> >+ <style type="text/css" py:content="inline_file('static/ui.css')"> >+ </style> I think this can be: <style type="text/css"> <xi:include href="../static/ui.css" parse="text" /> </style> >diff --git a/weeklyupdates/templates/message.xhtml b/weeklyupdates/templates/message.xhtml >+ <div> >+ <h1>${subject}</h1> Is the extra <div> necessary now that we're in a full HTML container?
Attachment #414778 - Flags: review?(benjamin) → review-
(Patch/bug mooted by subsequent weekly-updates commits.)
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
Really? The local-development work here seemed pretty valuable, it just needed some minor changes.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: