Re: [flask] Flask-Genshi updates
- From:
- Matthew Frazier
- Date:
- 2010-11-22 @ 02:47
On 11/21/2010 03:58 PM, Dag Odenhall wrote:
> I'd like Flask-Genshi to work with Flask-Theme; what's the best way to
> approach that goal?
The easiest way is to look at the Flask-Themes source code and docs*,
find all the stuff that has to do with Jinja2 templates**, and
reimplement those. So far, I can identify two major obstacles:
- You don't actually have the ability to plug custom loaders into
Flask-Genshi as of now, which is pretty much necessary to implement
theming given that they can be loaded from practically anywhere.
- I have no idea how you would implement the concept of the "active
theme" from within templates. (Genshi's docs are much less accessible
than Jinja2's.)
Fortunately, it's possible to do this on top of the existing
infrastructure for theme loaders and static files, which is about 75% of
the Flask-Themes code.
*
http://www.bitbucket.org/leafstorm/flask-themes/src/tip/flaskext/themes.py
and http://packages.python.org/Flask-Themes/
** This includes render_theme_template, the "theme" and "theme_static"
globals, and the theme template loader, as well as all the other support
functions they use.
--
Regards, Matthew Frazier
http://leafstorm.us/
Re: Flask-Genshi updates
- From:
- Dag Odenhall
- Date:
- 2010-11-21 @ 21:01
On Sun, 2010-11-21 at 21:58 +0100, Dag Odenhall wrote:
> I released a new version (0.5) of Flask-Genshi today. The previous
> release went unannounced, here's a list of changes from both:
>
> * Improved documentation
> * Templates local to a flask.Module
> * Context processors
> * Render templates from strings
> * Filters can take the context - needed for flatland
> * Genshi callback interface - useful for i18n and for use with
> Flask-Babel
> * A template_generated signal similar to flask.template_rendered
> * Per-render filters
> * Delayed initiation with init_app for factory pattern and for
> avoiding circular dependencies
> * Support for SVG templates
> * Adds itself to the app.extensions dictionary
>
> Deprecated features:
>
> * app.genshi_instance - use app.extensions['genshi'] instead
> * select_method - moved to private API Genshi._method_for
>
> It is my intention that Flask-Genshi should provide a complete and
> seamless Flask experience, if there's any Flask+Jinja feature that needs
> to be supported please let me know.
>
> Dan Jacob: Flask-Testing might should add support for
> flaskext.genshi.template_generated if it's importable - or would it be
> better if Flask-Genshi faked a Jinja template object and fired
> flask.template_rendered?
>
> I'd like Flask-Genshi to work with Flask-Theme; what's the best way to
> approach that goal?
>
> I'm considering a Flask-Chameleon extension, though I don't (currently)
> really need it myself. Is there any interest in this?
>
> http://packages.python.org/Flask-Genshi/
>
I should add that development moved to GitHub (might be obvious from the
ribbon);
http://github.com/dag/flask-genshi
Re: [flask] Re: Flask-Genshi updates
- From:
- danjac354@gmail.com
- Date:
- 2010-11-21 @ 22:01
Hi Dag,
I think it would be better if Flask-Testing made it easier to
configure template_rendered e.g. through calling an overridable method
- it may be that other template engines will have to be supported. I'm
open to ideas on this.
On 21 November 2010 21:01, Dag Odenhall <dag.odenhall@gmail.com> wrote:
> On Sun, 2010-11-21 at 21:58 +0100, Dag Odenhall wrote:
>> I released a new version (0.5) of Flask-Genshi today. The previous
>> release went unannounced, here's a list of changes from both:
>>
>> * Improved documentation
>> * Templates local to a flask.Module
>> * Context processors
>> * Render templates from strings
>> * Filters can take the context - needed for flatland
>> * Genshi callback interface - useful for i18n and for use with
>> Flask-Babel
>> * A template_generated signal similar to flask.template_rendered
>> * Per-render filters
>> * Delayed initiation with init_app for factory pattern and for
>> avoiding circular dependencies
>> * Support for SVG templates
>> * Adds itself to the app.extensions dictionary
>>
>> Deprecated features:
>>
>> * app.genshi_instance - use app.extensions['genshi'] instead
>> * select_method - moved to private API Genshi._method_for
>>
>> It is my intention that Flask-Genshi should provide a complete and
>> seamless Flask experience, if there's any Flask+Jinja feature that needs
>> to be supported please let me know.
>>
>> Dan Jacob: Flask-Testing might should add support for
>> flaskext.genshi.template_generated if it's importable - or would it be
>> better if Flask-Genshi faked a Jinja template object and fired
>> flask.template_rendered?
>>
>> I'd like Flask-Genshi to work with Flask-Theme; what's the best way to
>> approach that goal?
>>
>> I'm considering a Flask-Chameleon extension, though I don't (currently)
>> really need it myself. Is there any interest in this?
>>
>> http://packages.python.org/Flask-Genshi/
>>
>
> I should add that development moved to GitHub (might be obvious from the
> ribbon);
>
> http://github.com/dag/flask-genshi
>
>
>
Re: [flask] Re: Flask-Genshi updates
- From:
- Dag Odenhall
- Date:
- 2010-11-21 @ 23:24
On Sun, 2010-11-21 at 22:01 +0000, danjac354@gmail.com wrote:
> Hi Dag,
>
> I think it would be better if Flask-Testing made it easier to
> configure template_rendered e.g. through calling an overridable method
> - it may be that other template engines will have to be supported. I'm
> open to ideas on this.
>
Sounds good; possibly it could support known templating extensions out
of the box and provide hooks for adding more?
Maybe you could simply provide your own signal taking the template name
and context:
@flask.template_rendered.connect_via(app)
def jinja_rendered(template, context):
flaskext.testing.template_rendered.send(app, template.name, context)
try:
from flaskext.genshi import template_generated
except ImportError:
pass
else:
@flaskext.genshi.template_generated.connect_via(app)
def genshi_rendered(template, context):
flaskext.testing.template_rendered.send(app, template.filename, context)