Skip to main content

SCSS for TurboGears2, fast middleware to use SCSS for all your CSS

Project description

About tgext.scss

SCSS is a cool and useful extension to CSS, but it always required some effort to be used and even specific production environment configurations for some systems.

tgext.scss has born to make life easier for TurboGears2 developers, it will rely on python-scss to serve all the files in your public directory that end with .scss as text/css converting them and minifying them.

Installing

tgext.scss can be installed both from pypi or from bitbucket:

easy_install tgext.scss

should just work for most of the users

Enabling tgext.scss

Using tgext.scss is really simple, you edit your config/middeware.py and just after the #Wrap your base TurboGears 2 application with custom middleware here comment wrap app with SCSSMiddleware:

from tgext.scss import SCSSMiddleware

make_base_app = base_config.setup_tg_wsgi_app(load_environment)

def make_app(global_conf, full_stack=True, **app_conf):
    app = make_base_app(global_conf, full_stack=True, **app_conf)

    # Wrap your base TurboGears 2 application with custom middleware here
    app = SCSSMiddleware(app)

    return app

Now you just have to put your .scss file inside public/css and they will be served as CSS.

How much it will slow me down?

Actually as tgext.scss uses aggressive caching it won’t you slow down at all, indeed it might even be able to serve you CSS files even faster.

Here is the report of a benchmark (absolutely not reliable as every other benchmark) made on paster serving the same CSS file or SCSS:

$ /usr/sbin/ab -n 1000 http://localhost:8080/css/style.css
Requests per second:    961.26 [#/sec] (mean)

$ /usr/sbin/ab -n 1000 http://localhost:8080/css/style.scss
Requests per second:    1200.34 [#/sec] (mean)

In these case SCSS is even faster than directly serving the same css file as it is served from memory (due to caching performed by tgext.scss) and is also minified resulting in less bandwith usage.

Off course this means that tgext.scss will require a bit more memory than serving your css files alone, but as css files are usually small this amount is trascurable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgext.scss-0.1.1dev.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file tgext.scss-0.1.1dev.tar.gz.

File metadata

File hashes

Hashes for tgext.scss-0.1.1dev.tar.gz
Algorithm Hash digest
SHA256 f40b10a16bd7ba2584f9e613d59208046ba52af29cfc2aa5dcb5d44dc19ab1f3
MD5 cc803e10b09f3995e38deb54570c541a
BLAKE2b-256 7d60f9a3fb4c840f633d4bffeb1420e2e9b83c993256fdb0234fa89c64c00e08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page