0

I'm new to Flask but have experience with PHP. I know there are session variables and global variables just as in PHP, but what do the contexts actually mean? I read the documentation but could not understand whet it was saying.

What are the application and request contexts, and what the is app.app_context()?

davidism
  • 121,510
  • 29
  • 395
  • 339
jack wilson
  • 145
  • 1
  • 13
  • Is it something that you need to worry about right this instant? That is to say, are you developing something which knowledge of this is pivotal?' – Makoto Jan 08 '15 at 04:35
  • 1
    (This might seem harsh, but I'd encourage you to only learn it when you actually need to use it. It'd just wind up confusing you more.) – Makoto Jan 08 '15 at 04:35
  • No sir but im just readin the various aspects of flask frame work.?Are these not so important? – jack wilson Jan 08 '15 at 04:38
  • 1
    Perhaps the answers to this question will be helpful: http://stackoverflow.com/questions/20036520/what-is-the-purpose-of-flasks-context-stacks – Mark Hildreth Jan 08 '15 at 21:53

1 Answers1

1

app.app_context loads the application and any extentions you have loaded. A request context is loaded when you are dealing with a request.

A good example.

If you have a background cron that does some database work, you'll need to make use of app_context to get access to the models.

You'll be a in request context pretty much whenever you're handling a view.

PsyKzz
  • 740
  • 4
  • 14