python - Attribute never updates between requests to a FlaskView -


i've class this:

class  ma_class(flaskview):   route_base = '/'    state = false    @route('/load')   def load(self):       self.state = true       return 'load : ok'    @route('/stuff')   def do_something(self)     if not self.state:         return 'you must invoke load method'  

when send request url/load load : ok in response.

but after, when send request url/stuff you must invoke load method.

self.state hasn't changed, , have no idea why.

thanks reading

http stateless. means 1 request not know second request , on, unless tell in way. if using flask, can use "session" achieve that. sessions way save information acorss multiple requests (e.g login).

from flask import session  class  ma_class(flaskview):   route_base = '/'   @route('/load') def load(self):    session['state'] = true   return 'load : ok'  @route('/stuff') def do_something(self)    if 'state' not in session:        return 'you must invoke load method'  

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -