This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Breve template engine renderer for Pyramid framework that uses asset specification to locate and load templates. Please use GitHub repository to access latest sources, report bugs and make feature requests

Installation

If you prefer pip:

$ pip install pyramid-breve

Otherwise:

$ easy_install pyramid-breve

Usage

Call config.include('pyramid_breve') in your WSGI applicatication factory function as following:

def main(global_config, **settings):
    config = Configurator(settings=settings)

    config.include('pyramid_breve')

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.scan()

    return config.make_wsgi_app()

Another way is to add it to pyramid.includes in your INI-file:

[app:main]
pyramid.includes = pyramid_breve

Now use it to render templates:

# using absolute asset specification
@view_config(route_name='home', renderer='my.lovely.app:templates/home.b')
def home_view(request):
    return {real: 'content'}

# using relative asset specification
@view_config(route_name='login', renderer='templates/login.b')
def login_view(request):

Configuration parameters

There are few configuration parameters that control rendering. They can be set in INI-file as following:

[app:main]
breve.tags = my_package.breve.tags
breve.doctype = html
# optionally, enforce default package name if pyramid-breve fails to detect it
breve.default_package = myapp

Breve renderer accepts following parameters:

breve.default_package
Package name to use for resolving relative asset specifications, i.e. assets without explicit package name. Pyramid-breve tries to detect your application name and use it as default package name but it’s a tricky business and this parameter allowes to enforce default package name.
breve.tags
This parameter will be resolved from dotted name string into Python object. Default is breve.tags.html.tags.
breve.doctype
“<!DOCTYPE html>” or just “html”. Default is content of breve.tags.html.doctype.
breve.xmlns
Will be sent as-is to the constructor. Default is content of breve.tags.html.xmlns.
breve.fragment
This boolean variable will be used as fragment parameter to breve.Template.render call. This parameter can also be controlled by setting breve_fragment template variable as following:
@view_config(renderer='templates/home.b')
def home_view(request):
    return {
        # other variables used in template
        'breve_fragment': True,
        }

Template variable breve_fragment overrides global breve.fragment setting. If none is set default is False.

Template file modification monitoring

Starting from version 0.6dev there is pyramid_breve.monitor.IFileMonitor interface. Implementations of that interface can be used to help pyramid_breve.renderer.TemplateLoader to get template file status without calling os.stat each time template is about to be rendered.

There is pyramid_breve.monitor.IntervalMonitor implementation of that interface which is used by BreveRendererFactory by default. That class simply caches os.stat value for fixed amount of time. Its constructor accepts single parameter interval that should be interval in seconds between invalidating cached values. This parameter can be configure via INI-file variable breve.monitor_interval like following:

[app:main]
# cache os.stat calls for 15 seconds
breve.monitor_interval = 15

It is possible to implement custom IFileMonitor using more advanced techiques, like inotify or File Alteration Monitor features.

Lets create simple IFileMonitor implementation and configure pyramid_breve to use it.

First, we need to implement IFileMonitor interface:

# myapp/utils.py

from zope.interface import implements
from pyramid_breve.monitor import IFileMonitor

class DummyMonitor(object):

    implements(IFileMonitor)

    def last_modified(self, name):
        # Never even look at real modification time and
        # make it look like templates never change
        return 0

monitor = DummyMonitor()

Use breve.monitor variable in INI-file:

[app:main]
breve.monitor = myapp.utils.monitor
Release History

Release History

0.7.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.4dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.3dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.2dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6.1dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.6dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.2dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.1dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pyramid-breve-0.7.0.tar.bz2 (5.0 kB) Copy SHA256 Checksum SHA256 Source Jul 25, 2014
pyramid-breve-0.7.0.tar.gz (4.6 kB) Copy SHA256 Checksum SHA256 Source Jul 25, 2014
pyramid-breve-0.7.0.zip (10.3 kB) Copy SHA256 Checksum SHA256 Source Jul 25, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting