From 7f1e01e9045fccc117b707d55ad0ff37dddee9e9 Mon Sep 17 00:00:00 2001 From: zmsbot Date: Thu, 3 Oct 2024 20:04:04 +0200 Subject: [PATCH] improved performance of headless requests Ref: https://github.com/zms-publishing/ZMS/issues/316 --- Products/zms/_cachemanager.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Products/zms/_cachemanager.py b/Products/zms/_cachemanager.py index 7e2218cb0..1d2b42daf 100644 --- a/Products/zms/_cachemanager.py +++ b/Products/zms/_cachemanager.py @@ -19,6 +19,8 @@ # Imports. from Products.zms import standard +headless_http_request = standard.create_headless_http_request() + class Buff(object): pass @@ -43,7 +45,7 @@ def getReqBuffId(self, key): # Clear buffered values from Http-Request. # -------------------------------------------------------------------------- def clearReqBuff(self, prefix='', REQUEST=None): - request = self.get('REQUEST', standard.create_headless_http_request()) + request = self.get('REQUEST', headless_http_request ) buff = request.get('__buff__', Buff()) reqBuffId = self.getReqBuffId(prefix) if len(prefix) > 0: @@ -60,7 +62,7 @@ def clearReqBuff(self, prefix='', REQUEST=None): # @throws Exception # -------------------------------------------------------------------------- def fetchReqBuff(self, key, REQUEST=None): - request = self.get('REQUEST', standard.create_headless_http_request()) + request = self.get('REQUEST', headless_http_request ) buff = request['__buff__'] reqBuffId = self.getReqBuffId(key) return getattr(buff, reqBuffId) @@ -71,7 +73,7 @@ def fetchReqBuff(self, key, REQUEST=None): # Returns value and stores it in buffer of Http-Request. # -------------------------------------------------------------------------- def storeReqBuff(self, key, value, REQUEST=None): - request = self.get('REQUEST', standard.create_headless_http_request()) + request = self.get('REQUEST', headless_http_request ) buff = request.get('__buff__', None) if buff is None: buff = Buff()