Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caching probably not perfect #1

Open
faassen opened this issue Jan 7, 2015 · 10 comments
Open

caching probably not perfect #1

faassen opened this issue Jan 7, 2015 · 10 comments

Comments

@faassen
Copy link
Member

faassen commented Jan 7, 2015

I'm recreating the environment each time a template gets created now. This probably breaks caching when template inheritance is in use. (need to review the code)

It would be nice if we could share the environment if it's the same. I'm not entirely sure how to proceed.

One way to improve would be to pass in a template search path and a template name in from Morepath instead, and then cache environments on a search path basis.

@faassen
Copy link
Member Author

faassen commented Jan 7, 2015

It'd be nice if we could have one environment per app, but the loader cannot be configured that early as the app itself has no knowledge where the templates may be - only the individual view directives know this.

@RonnyPfannschmidt
Copy link

i'd suggest to discover loaders at the same time as views are discovered,
and then on first use instanciate a environment with all loaders

my guess is, the common case is one loader per app and i wonder if more complex ones should be approached with yagni

@faassen
Copy link
Member Author

faassen commented Jan 7, 2015

There is just one loader per environment though. Can have multiple items in search path but that seems wrong too. Perhaps a loader for /...

@RonnyPfannschmidt
Copy link

@RonnyPfannschmidt
Copy link

btw, i still dont get why only views can know where templates are,
as far as im concened all they should know is what templates they render to

@faassen
Copy link
Member Author

faassen commented Jan 7, 2015

Choice loader is a search path and search path is not what I want.

Though that reminds me of common practice to override templates through search path stuff in Jinja2. Not sure how to support (or even if). Maybe a loader that can load views..

See here the docs on how the Morepath template integration works now:

http://morepath.readthedocs.org/en/latest/templates.html

@RonnyPfannschmidt
Copy link

the scheme seems rather impractical/uncommon, you need to make a custom jinja loader that maps paths to packages i suppose,
i'd prefer to have oine template directory instead that mirrors the app structure

@RonnyPfannschmidt
Copy link

bascially sane inheritance would be total hell with all templates are next to the modules

@faassen
Copy link
Member Author

faassen commented Jan 7, 2015

You don't have to put the templates next to the modules. You can put them in a subdir next to the modules. There's an actual test that tests inheritance already:

https://github.com/morepath/more.jinja2/blob/master/more/jinja2/tests/fixtures/template_inheritance.py

I don't think the scheme is impractical at all. Anyway, all this got me thinking about how to override templates the Morepath way, and I have an idea..

@RonnyPfannschmidt
Copy link

hmm, maybe im having a waay different structure in mind, but im coming from the common flask and/or django setup there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants