Esempio n. 1
0
 def _wrapper(self, **kwargs):
     request = cherrypy.serving.request
     if _caching.get(**kwargs):
         request.handler = None
     else:
         if request.cacheable:
             # Note the devious technique here of adding hooks on the fly
             request.hooks.attach("before_finalize", _caching.tee_output, priority=90)
Esempio n. 2
0
 def _wrapper(self, **kwargs):
     request = cherrypy.serving.request
     if _caching.get(**kwargs):
         request.handler = None
     else:
         if request.cacheable:
             # Note the devious technique here of adding hooks on the fly
             request.hooks.attach('before_finalize',
                                  _caching.tee_output,
                                  priority=90)
Esempio n. 3
0
    def _wrapper(self, invalid_methods=("POST", "PUT", "DELETE"), **kwargs):
        request = cherrypy.request

        if not hasattr(cherrypy, "_cache"):
            # Make a process-wide Cache object.
            cherrypy._cache = kwargs.pop("cache_class", _caching.MemoryCache)()

            # Take all remaining kwargs and set them on the Cache object.
            for k, v in kwargs.iteritems():
                setattr(cherrypy._cache, k, v)

        if _caching.get(invalid_methods=invalid_methods):
            request.handler = None
        else:
            if request.cacheable:
                # Note the devious technique here of adding hooks on the fly
                request.hooks.attach("before_finalize", _caching.tee_output, priority=90)
Esempio n. 4
0
 def _wrapper(self, invalid_methods=("POST", "PUT", "DELETE"), **kwargs):
     request = cherrypy.request
     
     if not hasattr(cherrypy, "_cache"):
         # Make a process-wide Cache object.
         cherrypy._cache = kwargs.pop("cache_class", _caching.MemoryCache)()
         
         # Take all remaining kwargs and set them on the Cache object.
         for k, v in kwargs.iteritems():
             setattr(cherrypy._cache, k, v)
     
     if _caching.get(invalid_methods=invalid_methods):
         request.handler = None
     else:
         if request.cacheable:
             # Note the devious technique here of adding hooks on the fly
             request.hooks.attach('before_finalize', _caching.tee_output,
                                  priority = 90)
Esempio n. 5
0
 def _wrapper(self, **kwargs):
     request = cherrypy.serving.request
     if _caching.get(**kwargs):
         request.handler = None
     elif request.cacheable:
         request.hooks.attach('before_finalize', _caching.tee_output, priority=90)