python - Request variable not found in pluggable view -


i have pluggable view defined follows

class listview(view):     methods = ["get", "post"]      def __init__(self, model, template_name="list_view.html"):          self.model = model                    self.template_name = template_name      def dispatch_request(self, *args, **kwargs):         if request.method == "get":            objects = self.model.query.all()            return render_template(self.template_name,                                 objects=objects)         else:            #do post request 

i'm trying create pluggable view that'll handle both , post requests. when try above, following error however

nameerror: global name 'request' not defined 

according flask docs, request should present in dispatch_request method, isn't in case. i'm using flask 0.10.1

request global context variable; need import in module:

from flask import request 

see quickstart documentation on accessing request data; no different pluggable views.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -