Commit b3a62bd2 by David Ormsbee

LMS startup optimization: Load pynliner locally.

pynliner imports cssutils, which has an expensive initialization. All
told, it can account for 15-20% of "fast" LMS startup (without asset
compilation). So we're going to load it locally here so that we delay
that one-time hit until we actually do the (rare) operation that is
sending a credit notification email.
parent c8f7587f
......@@ -5,7 +5,6 @@ This file contains utility functions which will responsible for sending emails.
import os
import logging
import pynliner
import urlparse
import uuid
import HTMLParser
......@@ -145,6 +144,13 @@ def with_inline_css(html_without_css):
with open(css_filepath, "r") as _file:
css_content = _file.read()
# pynliner imports cssutils, which has an expensive initialization. All
# told, it can account for 15-20% of "fast" LMS startup (without asset
# compilation). So we're going to load it locally here so that we delay
# that one-time hit until we actually do the (rare) operation that is
# sending a credit notification email.
import pynliner
# insert style tag in the html and run pyliner.
html_with_inline_css = pynliner.fromString('<style>' + css_content + '</style>' + html_without_css)
return html_with_inline_css
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment