librelist archives

« back to archive

[ANN] Garter, a library of useful Flask-related functions

[ANN] Garter, a library of useful Flask-related functions

From:
Steve Losh
Date:
2010-05-05 @ 12:32
I've been playing around with Flask a bit lately and am loving it.  It's a
great fit for smaller projects that don't need a massive framework like 
Django, and it somehow feels cleaner than CherryPy.

I've looked at Bottle and it seems very similar, but Flask's documentation
looks *much* nicer which is important when you're trying to read through 
all of it.

During my experimentation I noticed a few things that seemed like prime 
candidates for inclusion in a library of Flask-related utilities, so I 
went ahead and made one:

Garter
http://sjl.bitbucket.org/garter/

Right now there are three functions in Garter:

* The permalink decorator is taken straight from the Flask snippet site.  
It's useful enough that I don't want to have to copy and paste the code 
into each Flask project I make.

* The LessCSS support is something I hacked together to make my life 
easier.  If you use LessCSS you might want to take a look.

* The CSRF protection module started off as a copy of the snippet on the 
Flask site.  I realized I needed a way to exempt specific views from 
protection, so I added that in.  I'd appreciate feedback on how to do it 
the *right* way -- I get the feeling that it could be better.

Pull requests are always welcome -- if you have some functions of your own
that you think might be useful you can fork Garter on BitBucket or GitHub:

http://bitbucket.org/sjl/garter/
http://github.com/sjl/garter/

--
Steve Losh
http://stevelosh.com/

Re: [flask] [ANN] Garter, a library of useful Flask-related functions

From:
Armin Ronacher
Date:
2010-05-05 @ 16:15
Hi,

On 2010-05-05 2:32 PM, Steve Losh wrote:
> During my experimentation I noticed a few things that seemed like
> prime candidates for inclusion in a library of Flask-related
> utilities, so I went ahead and made one
I would love to see all flask addon libraries to end up in a flaskext 
namespace.  Would be cool if you could alter your project to be 
importable as flaskext.gartner instead of just gartner.  The big 
advantage is that it keeps PyPI clean and it's easier for users to see 
what goes with which framework.

This is done using namespace packages, so like this:

1. create a folder called flaskext with a __init__.py file
    with this exact contents:

    __import__('pkg_resources').declare_namespace(__name__)

2. Put your package into that flaskext folder.


Sphinx showcases that pretty well: http://bit.ly/djg4Sj


Regards,
Armin