示例#1
0
文件: cache.py 项目: yanghao/xiaoyezi
 def __init__(self, request=None, response=None, mc=None, ignore_trailing_slash=True):
     RequestHandler.__init__(self, request, response)
     self.ignore_trailing_slash = ignore_trailing_slash
     self.log = logging.getLogger(self.__class__.__name__)
     if mc == None:
         raise "No Memcache Client provided"
     else:
         self.mc = mc
示例#2
0
    def dispatch(self):
        self.session_store = sessions.get_store(factory=sessions.SessionStore, key='webapp2_extras.sessions.SessionStore', request=self.request)
        self.session_flash = sessions.get_store(factory=sessions.SessionDict, key='webapp2_extras.sessions.SessionDict', request=self.request)

        try:
            RequestHandler.dispatch(self)
        finally:
            self.session_store.save_sessions(self.response)
示例#3
0
文件: main.py 项目: hansent/dwollaup
 def dispatch(self):
     self.session_store = sessions.get_store(request=self.request)
     if not self.session.get('user'):
         self.redirect(self.app_url('/login'))
     self.user = db.get( db.Key(session['user']) )
     try:
         RequestHandler.dispatch(self)
     finally:
         self.session_store.save_sessions(self.response)
示例#4
0
 def dispatch(self):
     # Get a session store for this request.
     self.session_store = sessions.get_store(request=self.request)
     try:
         # Dispatch the request.
         RequestHandler.dispatch(self)
     finally:
         # Save all sessions.
         self.session_store.save_sessions(self.response)
示例#5
0
文件: main.py 项目: hansent/dwollaup
 def dispatch(self):
     self.session_store = sessions.get_store(request=self.request)
     if not self.session.get("user"):
         self.redirect(self.app_url("/login"))
     self.user = db.get(db.Key(session["user"]))
     try:
         RequestHandler.dispatch(self)
     finally:
         self.session_store.save_sessions(self.response)
    def dispatch(self):
        # Get a session store for this request.
        self.session_store = sessions.get_store(request=self.request)

        try:
            # Dispatch the request.
            RequestHandler.dispatch(self)
        finally:
            # Save all sessions.
            self.session_store.save_sessions(self.response)
示例#7
0
 def dispatch(self):
     self.session_store = sessions.get_store(request=self.request)
     try:
         RequestHandler.dispatch(self)
     except Exception as error:
         postArgs = dict(self.request.POST)
         if POST_USER_PASSWORD in postArgs:
             postArgs.pop(POST_USER_PASSWORD)
         logging.error("Unhandled error "+str(type(error))+" "+str(error)+" "+error.message+" "+str(postArgs))
         self.response.write(RESPONSE_UNHANDLED_ERROR)
     finally:
         self.session_store.save_sessions(self.response)
示例#8
0
    def test_request_handler_get_config(self):
        app = WSGIApplication()

        handler = RequestHandler(app, None, None)

        assert handler.get_config('resources.i18n', 'locale') == 'en_US'
        assert handler.get_config('resources.i18n', 'locale', 'foo') == 'en_US'
        assert handler.get_config('resources.i18n') == {
            'locale': 'en_US',
            'timezone': 'America/Chicago',
            'required': REQUIRED_VALUE,
        }
示例#9
0
    def dispatch(self):
        # Get a session store for this request.
        # See this for more info on webapp2 sessions:
        # http://webapp-improved.appspot.com/api/webapp2_extras/sessions.html
        self.session_store = sessions.get_store(request=self.request)

        i18n.get_i18n().set_locale('en')

        try:
            # Dispatch the request.
            RequestHandler.dispatch(self)
        finally:
            # Save all sessions.
            self.session_store.save_sessions(self.response)
示例#10
0
 def dispatch(self):
   # Get a session store for this request.
   # See this for more info on webapp2 sessions:
   # http://webapp-improved.appspot.com/api/webapp2_extras/sessions.html
   self.session_store = sessions.get_store(request=self.request)
   
   i18n.get_i18n().set_locale('en')
   
   try:
     # Dispatch the request.
     RequestHandler.dispatch(self)
   finally:
     # Save all sessions.
     self.session_store.save_sessions(self.response)
 def initialize(self, *args, **kwargs):
     RequestHandler.initialize(self, *args, **kwargs)
     uid = self.read_secure_cookie('user_id')
     self.user = uid and User.by_id(int(uid))
     self.url = self.request.route_args[0] if len(self.request.route_args) > 0 else '/'
     v = self.request.get('v')
     if v and v.isdigit():
         self.v = int(v)
         p = Page.by_id(int(self.v), self.url)
         if p:
             self.page = p
         else:
             self.error(404)
     else:
         self.page = Page.by_url(self.url)
示例#12
0
文件: web.py 项目: westmark/maeve
  def dispatch(self):
    self.session_store = sessions.get_store(request=self.request)

    try:
      RequestHandler.dispatch(self)
    except:
      import traceback
      logging.error(traceback.format_exc())
      d = dict(stacktrace=traceback.format_exc(),
               req=self.request)
      self.render_response('error/general.html', d)
    finally:
      self.session_store.save_sessions(self.response)

      if 'User-Agent' in self.request.headers and 'msie' in self.request.headers['User-Agent'].lower():
        self.response.headers['X-UA-Compatible'] = 'IE=edge,chrome=1'
示例#13
0
    def dispatch(self):
        """
        Dispatches the request after grabbing the ``session_store`` and providing access to the current
        `webapp2.Request`_ 's session.

        This will first check if there's a handler_method defined in the matched route, and if not it'll use the
        method correspondent to the request method (``get()``, ``post()`` etc).
        """
        # Get a session store for this request.
        self.session_store = sessions.get_store(factory=SessionStore, request=self.request)

        try:
            # Dispatch the request.
            RequestHandler.dispatch(self)
        finally:
            # Save all sessions.
            self.session_store.save_sessions(self.response)
示例#14
0
    def dispatch(self):
        # memories of bobo traverse
        name = self.request.path_info_pop()
        if name:
            if name.endswith('.png') and self.Form.hasImageField(name[:-4]):
                return self.getImage(self.wobObj, name[:-4])
            else:
                return self.traverseTo(name)

        return RequestHandler.dispatch(self)
示例#15
0
    def dispatch(self):
        # memories of bobo traverse
        name = self.request.path_info_pop()
        if name:
            if name.endswith('.png') and self.Form.hasImageField(name[:-4]):
                return self.getImage(self.wobObj, name[:-4])
            else:
                return self.traverseTo(name)

        return RequestHandler.dispatch(self)
示例#16
0
 def dispatch(self):
     self.session_store = sessions.get_store(request=self.request)
     try:
         RequestHandler.dispatch(self)
     except UnicodeDecodeError:
         logging.warning("Username with bad characters")
         self.response.write(RESPONSE_USER_BAD_USERNAME)
     except Exception as error:
         try:
             postArgs = dict(self.request.POST)
             if POST_USER_PASSWORD in postArgs:
                 postArgs.pop(POST_USER_PASSWORD)
             logging.error(
                 "Unhandled error \n" + traceback.format_exc() + str(postArgs))
         except Exception:
             logging.error("Unhandled error, unprintable POST args \n" + traceback.format_exc())
         self.response.write(RESPONSE_UNHANDLED_ERROR)
     finally:
         self.session_store.save_sessions(self.response)
示例#17
0
 def initialize(self, *a, **kw):
     RequestHandler.initialize(self, *a, **kw)
     if self.request.url.endswith('.json'):
         self.format = 'json'
     else:
         self.format = 'html'
示例#18
0
 def __init__(self, request, response, wobObj=None):
     RequestHandler.__init__(self, request, response)
     self.wobObj = wobObj
示例#19
0
 def __init__(self, request, response):
     RequestHandler.initialize(self, request, response)
     self.fd = self.request.POST
     self.vessel = Vessel(parent=Owner.get_key())
     self.valid = True
示例#20
0
 def dispatch(self):
     self.session_store = sessions.get_store(request=self.request)
     try:
         RequestHandler.dispatch(self)
     finally:
         self.session_store.save_sessions(self.response)
示例#21
0
 def __init__(self, request, response):
     RequestHandler.initialize(self, request, response)
     self.fd = self.request.POST
     self.vessel = Vessel(parent=Owner.get_key())
     self.valid = True
示例#22
0
def build_uri(handler, key_id):
    return RequestHandler.uri_for(handler, 'workflow', _full=True) + "?id=" + str(key_id)
示例#23
0
 def dispatch(self):
     RequestHandler.dispatch(self)
     self.response.headers['SessionMock'] = json.dumps(self.session)
示例#24
0
 def __init__(self, request, response):
     RequestHandler.initialize(self, request, response)
     self.fd = self.request.POST
     self.err = {}
示例#25
0
 def __init__(self, request, response):
     RequestHandler.initialize(self, request, response)
     self.fd = self.request.POST
     self.err = {}
示例#26
0
 def initialize(self, *a, **kw): #runs on every request and checks if user is logged in
     RequestHandler.initialize(self, *a, **kw)
     sid = self.read_secure_cookie('student_id')
     self.student = sid and Student_by_id(int(sid))
示例#27
0
 def dispatch(self):
     self.session_store = get_store(request=self.request)
     try:
         RequestHandler.dispatch(self)
     finally:
         self.session_store.save_sessions(self.response)
示例#28
0
 def dispatch(self):
   RequestHandler.dispatch(self)
   self.response.headers['SessionMock'] = json.dumps(self.session)
示例#29
0
    def __init__(self, request=None, response=None):
        RequestHandler.__init__(self, request, response)

        # Retrieve user by his cookie
        self.user = User.get_by_cookie(self.request.cookies.get("uid"))
示例#30
0
 def __init__(self, request, response, wobObj=None):
     RequestHandler.__init__(self, request, response)
     self.wobObj = wobObj
示例#31
0
 def initialize(self, *a, **kw):
     RequestHandler.initialize(self, *a, **kw)
     uid = self.read_secure_cookie('user_id')
     self.user = uid and User.by_id(int(uid))