Unable to render a template without request context #557

Closed
rslinckx opened this Issue Jul 20, 2012 · 2 comments

Comments

4 participants
@rslinckx

With the recent introduction of flask.app_context() it is now possible to have code running in the context of an app, but without having a web request active.

I would like to be able to use render_template while in an app context but there are some code paths that assume there is an active request context while doing so.

The following code snippets should be adapted:

It seems odd to not be able to render a template without a request, obviously the user has to make sure that templates rendered in an app context don't use request-related references but that seems quite reasonable.

Do you think this makes sense ? If yes, then i can provide a patch to do that, and if you think of any other issues related to this i'll be glad to fix them.

Thanks !

@calvinwyoung

This comment has been minimized.

Show comment Hide comment
@calvinwyoung

calvinwyoung Nov 12, 2012

+1

I often need to render templates outside of a request context, and creating a test request context for this purpose has always seemed like a pretty dirty hack.

+1

I often need to render templates outside of a request context, and creating a test request context for this purpose has always seemed like a pretty dirty hack.

@soulseekah

This comment has been minimized.

Show comment Hide comment
@soulseekah

soulseekah Nov 13, 2012

Contributor

I think this has already been taken care of in commit f34c028

Templates can now be rendered without request context.

This issue should be closed, if possible.

Contributor

soulseekah commented Nov 13, 2012

I think this has already been taken care of in commit f34c028

Templates can now be rendered without request context.

This issue should be closed, if possible.

@mitsuhiko mitsuhiko closed this Jan 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment