Skip to content

Commit

Permalink
fix: performance of headless request creation (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho authored Oct 3, 2024
1 parent 79bd932 commit ac35c27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Products/zms/_cachemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# Imports.
from Products.zms import standard

headless_http_request = standard.create_headless_http_request()

class Buff(object):
pass

Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Products/zms/zmsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def default(*args, **kwargs):
abs_url = args[1]['abs_url']
forced = args[1]['forced']
if context.getConfProperty('ZMSObject.getAbsoluteUrlInContext', False):
if context.getHome() != context.getHome():
if context.getHome() != self.getHome():
protocol = context.getConfProperty('ASP.protocol', 'http')
domain = context.getConfProperty('ASP.ip_or_domain', None)
if domain:
Expand Down

0 comments on commit ac35c27

Please sign in to comment.