sassutils.wsgi — WSGI middleware for development purpose

class sassutils.wsgi.SassMiddleware(app, manifests, package_dir={}, error_status='200 OK')

WSGI middleware for development purpose. Every time a CSS file has requested it finds a matched Sass/SCSS source file and then compiled it into CSS.

It shows syntax errors in three ways:

Heading comment

The result CSS includes detailed error message in the heading CSS comment e.g.:

/*
Error: invalid property name
*/
Red text in body:before

The result CSS draws detailed error message in :before pseudo-class of body element e.g.:

body:before {
    content: 'Error: invalid property name';
    color: maroon;
    background-color: white;
}

In most cases you could be aware of syntax error by refreshing your working document because it will removes all other styles and leaves only a red text.

logging

It logs syntax errors if exist during compilation to sassutils.wsgi.SassMiddleware logger with level ERROR.

To enable this:

from logging import Formatter, StreamHandler, getLogger
logger = getLogger('sassutils.wsgi.SassMiddleware')
handler = StreamHandler(level=logging.ERROR)
formatter = Formatter(fmt='*' * 80 + '\n%(message)s\n' + '*' * 80)
handler.setFormatter(formatter)
logger.addHandler(handler)

Or simply:

import logging
logging.basicConfig()
Parameters:

Changed in version 0.4.0: It creates also source map files with filenames followed by .map suffix.

New in version 0.8.0: It logs syntax errors if exist during compilation to sassutils.wsgi.SassMiddleware logger with level ERROR.

static quote_css_string(s)

Quotes a string as CSS string literal.