Skip to content

Commit

Permalink
Merge branch 'main' into major-changes-by-unibe
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeier76 authored Oct 3, 2024
2 parents 05f6ade + 0e13c11 commit ced8fb7
Show file tree
Hide file tree
Showing 44 changed files with 567 additions and 564 deletions.
78 changes: 78 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "ZMS Development Environment",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": ["../docker-compose.yml", "docker-compose.yml"],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "zope",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/home/zope/",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
"shutdownAction": "stopCompose",
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
// Configure tool-specific properties.
// "customizations": {},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
// "ms-python.autopep8"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"python.defaultInterpreterPath": "/home/zope/venv/bin/python",
"window.zoomLevel": 0,
"git.ignoreMissingGitWarning": true,
"editor.minimap.enabled": false,
"editor.renderWhitespace": "all",
"editor.renderControlCharacters": false,
"workbench.iconTheme": "vs-minimal",
"files.associations": {
"*.zpt": "html",
"*.zcml": "xml"
},
"scm.alwaysShowActions": true,
"files.exclude": {
"*.pyc": true,
"*-all.min.*": true,
"**/cache/**": true,
"**/Data.*": true
},
"search.exclude": {
"**/apidocs/**": true
},
"files.eol": "\n",
"files.autoSave": "afterDelay",
"workbench.colorTheme": "Visual Studio Light",
"python.linting.enabled": false,
"python.formatting.provider": "none"
// "python.testing.pytestEnabled": false,
// "python.testing.unittestEnabled": true,
// "python.testing.unittestArgs": [
// "-v",
// "-s",
// "./tests",
// "-p",
// "test*.py"
// ],
// "[python]": {
// "editor.defaultFormatter": "ms-python.autopep8"
// }
}
}
}
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
6 changes: 6 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
zope:
volumes:
- .:/home/zope/workspace/:cached
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
40 changes: 40 additions & 0 deletions .vscode/Docker.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"folders": [
{
"name": "ZMS-Docker",
"path": "../.."
},
],

"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "ZMS-Docker",
"type": "debugpy",
"request": "launch",
"justMyCode": false,
"console": "integratedTerminal",
"program": "/home/zope/venv/bin/runwsgi",
"args": [
"--debug",
"--verbose",
"/home/zope/etc/zope.ini",
],
"env": {
"PYTHONUNBUFFERED":"1",
"CONFIG_FILE": "/home/zope/etc/zope.ini",
"INSTANCE_HOME": "/home/zope/",
"CLIENT_HOME": "/home/zope/",
"PYTHON": "/home/zope/venv/bin/python",
"SOFTWARE_HOME": "/home/zope/venv/bin"
},
"serverReadyAction":{
"pattern":"Serving on http://0.0.0.0:80",
"uriFormat": "http://admin:admin@127.0.0.1:80/manage_main",
"action": "openExternally",
},
},
]
}
}
File renamed without changes.
7 changes: 5 additions & 2 deletions Products/zms/_blobfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,15 @@ def equals(self, ob):
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
MyBlob._createCopy:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
def _createCopy(self, aq_parent, key):
def _createCopy(self, aq_parent, key, lang=None):
value = self._getCopy()
value.is_blob = True
value.aq_parent = aq_parent
value.key = key
value.lang = aq_parent.REQUEST.get( 'lang')
if hasattr(aq_parent, 'REQUEST'):
value.lang = aq_parent.REQUEST.get( 'lang')
elif lang is not None:
value.lang = lang
return value


Expand Down
9 changes: 6 additions & 3 deletions Products/zms/_cachemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
################################################################################

# Imports.
from Products.zms import standard

class Buff(object):
pass

Expand All @@ -40,7 +43,7 @@ def getReqBuffId(self, key):
# Clear buffered values from Http-Request.
# --------------------------------------------------------------------------
def clearReqBuff(self, prefix='', REQUEST=None):
request = self.REQUEST
request = self.get('REQUEST', standard.create_headless_http_request())
buff = request.get('__buff__', Buff())
reqBuffId = self.getReqBuffId(prefix)
if len(prefix) > 0:
Expand All @@ -57,7 +60,7 @@ def clearReqBuff(self, prefix='', REQUEST=None):
# @throws Exception
# --------------------------------------------------------------------------
def fetchReqBuff(self, key, REQUEST=None):
request = self.REQUEST
request = self.get('REQUEST', standard.create_headless_http_request())
buff = request['__buff__']
reqBuffId = self.getReqBuffId(key)
return getattr(buff, reqBuffId)
Expand All @@ -68,7 +71,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.REQUEST
request = self.get('REQUEST', standard.create_headless_http_request())
buff = request.get('__buff__', None)
if buff is None:
buff = Buff()
Expand Down
1 change: 0 additions & 1 deletion Products/zms/_confmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,6 @@ def getCatalogAdapter(self):
def getRegistry():
global __REGISTRY__
if __REGISTRY__ is None:
print("__REGISTRY__['confdict']",__REGISTRY__)
__REGISTRY__ = {}
try:
__REGISTRY__['confdict'] = ConfDict.get()
Expand Down
4 changes: 3 additions & 1 deletion Products/zms/_exportable.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ def toXhtml(self, REQUEST, deep=True):
# --------------------------------------------------------------------------
# Exportable.toXml:
# --------------------------------------------------------------------------
def toXml(self, REQUEST, deep=True, data2hex=False, multilang=True):
def toXml(self, REQUEST=None, deep=True, data2hex=False, multilang=True):
if REQUEST is None:
REQUEST = self.get('REQUEST', standard.create_headless_http_request())
xml = ''
xml += _xmllib.xml_header()
xml += _xmllib.getObjToXml( self, REQUEST, deep, base_path='', data2hex=data2hex, multilang=multilang)
Expand Down
15 changes: 8 additions & 7 deletions Products/zms/_objattrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
from Products.zms import _blobfields
from Products.zms import _globals


# ------------------------------------------------------------------------------
# getobjattrdefault
# ------------------------------------------------------------------------------
def getobjattrdefault(obj, obj_attr, lang):
request = obj.get('REQUEST', standard.create_headless_http_request())
v = None
datatype = obj_attr['datatype_key']
default = None
if datatype in range(len(_globals.datatype_map)):
default = obj_attr.get('default',_globals.datatype_map[datatype][1])
# Default inactive in untranslated languages.
if obj_attr['id'] == 'active' and len(obj.getLangIds()) > 1 and not obj.isTranslated(lang,obj.REQUEST):
if obj_attr['id'] == 'active' and len(obj.getLangIds()) > 1 and not obj.isTranslated(lang,request):
default = 0
if default is not None:
if datatype in _globals.DT_DATETIMES and default == '{now}':
Expand Down Expand Up @@ -467,7 +467,7 @@ def _getObjAttrValue(self, obj_attr, obj_vers, lang):
if isinstance(value,str):
value = None
elif value is not None:
value = value._createCopy( self, obj_attr['id'])
value = value._createCopy( self, obj_attr['id'], lang)
value.lang = lang

#-- DateTime-Fields.
Expand Down Expand Up @@ -595,7 +595,8 @@ def getObjProperty(self, key, REQUEST={}, par=None):
# attr({key0:value0,...,keyN:valueN}) -> setObjProperty(key0,value0),...
# --------------------------------------------------------------------------
def attr(self, *args, **kwargs):
request = kwargs.get('request',kwargs.get('REQUEST',self.REQUEST))
req = self.get('REQUEST', standard.create_headless_http_request())
request = kwargs.get('request',kwargs.get('REQUEST',req))
if len(args) == 1 and isinstance(args[0], str):
return self.getObjProperty( args[0], request, kwargs)
elif len(args) == 2:
Expand All @@ -609,8 +610,8 @@ def attr(self, *args, **kwargs):
# ObjAttrs.evalMetaobjAttr
# --------------------------------------------------------------------------
def evalMetaobjAttr(self, *args, **kwargs):
request = self.get('REQUEST', standard.create_headless_http_request())
root = self
request = self.REQUEST
key = args[0]
id = standard.nvl(request.get('ZMS_INSERT'), self.meta_id)
if key.find('.')>0:
Expand Down Expand Up @@ -693,7 +694,7 @@ def isActive(self, REQUEST):
value = tuple(value[:8]) + (0,)
dt = datetime.datetime.fromtimestamp(time.mktime(value) - (dst * 3600))
b = b and now > dt
if dt > now and self.REQUEST.get('ZMS_CACHE_EXPIRE_DATETIME', dt) >= dt:
if dt > now and self.get('REQUEST') and self.REQUEST.get('ZMS_CACHE_EXPIRE_DATETIME', dt) >= dt:
self.REQUEST.set('ZMS_CACHE_EXPIRE_DATETIME',dt)
# End time.
elif key == 'attr_active_end':
Expand All @@ -703,7 +704,7 @@ def isActive(self, REQUEST):
value = tuple(value[:8]) + (0,)
dt = datetime.datetime.fromtimestamp(time.mktime(value) - (dst * 3600))
b = b and dt > now
if dt > now and self.REQUEST.get('ZMS_CACHE_EXPIRE_DATETIME', dt) >= dt:
if dt > now and self.get('REQUEST') and self.REQUEST.get('ZMS_CACHE_EXPIRE_DATETIME', dt) >= dt:
self.REQUEST.set('ZMS_CACHE_EXPIRE_DATETIME',dt)
if not b: break
return b
Expand Down
14 changes: 9 additions & 5 deletions Products/zms/_pathhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from Products.zms import _fileutil
from Products.zms import _globals


# ------------------------------------------------------------------------------
# _pathhandler.validateId:
#
Expand Down Expand Up @@ -119,7 +118,7 @@ class PathHandler(object):
def __bobo_traverse__(self, TraversalRequest, name):
# If this is the first time this __bob_traverse__ method has been called
# in handling this traversal request, store the path_to_handle
request = self.REQUEST
request = self.get('REQUEST', standard.create_headless_http_request())
url = request.get('URL', '')
zmi = url.find('/manage') >= 0

Expand All @@ -142,7 +141,7 @@ def __bobo_traverse__(self, TraversalRequest, name):
TraversalRequest[ 'path_to_handle'].insert( i-1, path_physical[ i])

# Set language.
lang = request.get( 'lang')
lang = request.get( 'lang', self.getPrimaryLanguage())
if lang is None:
lang = self.getLanguageFromName(TraversalRequest['path_to_handle'][-1])
if lang is not None:
Expand Down Expand Up @@ -341,8 +340,13 @@ def __bobo_traverse__(self, TraversalRequest, name):
request.set('ZMS_EXT', zms_ext)
request.set('lang', lang)
return self

# If there's no more names left to handle, return the path handling

# Products.zms.standard.create_headless_http_request()
# has been called above for headless mode
if request.get('SERVER_NAME') == 'nohost':
return

# If there's no more names left to handle, return the path handling
# method to the traversal machinery so it gets called next
standard.raiseError('NotFound',''.join([x+'/' for x in TraversalRequest['path_to_handle']]))

Expand Down
7 changes: 4 additions & 3 deletions Products/zms/_textformatmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class TextFormatObject(object):
# Returns section-number.
# ----------------------------------------------------------------------------
def getSecNo( self):
request = self.get('REQUEST', standard.create_headless_http_request())
sec_no = ''
#-- [ReqBuff]: Fetch buffered value from Http-Request.
parentNode = self.getParentNode()
Expand All @@ -42,11 +43,11 @@ def getSecNo( self):
sec_no = parentNode.fetchReqBuff( '%s_%s'%(reqBuffId, self.id))
except:
levelnfc = parentNode.attr('levelnfc')
parentNode.storeReqBuff( '%s_levelnfc'%reqBuffId, levelnfc, self.REQUEST)
parentNode.storeReqBuff( '%s_levelnfc'%reqBuffId, levelnfc, request)
if levelnfc is not None and len(levelnfc) > 0:
parent_no = parentNode.getSecNo()
sectionizer = _globals.MySectionizer(levelnfc)
siblings = parentNode.filteredChildNodes( self.REQUEST)
siblings = parentNode.filteredChildNodes( request)
for sibling in siblings:
curr_no = ''
level = 0
Expand All @@ -62,7 +63,7 @@ def getSecNo( self):
if self == sibling:
sec_no = curr_no
#-- [ReqBuff]: Store value in buffer of Http-Request.
parentNode.storeReqBuff( '%s_%s'%(reqBuffId, sibling.id), curr_no, self.REQUEST)
parentNode.storeReqBuff( '%s_%s'%(reqBuffId, sibling.id), curr_no, request)
#-- [ReqBuff]: Return value.
return sec_no

Expand Down
7 changes: 4 additions & 3 deletions Products/zms/_zreferableitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# Product Imports.
from Products.zms import standard


# ------------------------------------------------------------------------------
# isMailLink:
# ------------------------------------------------------------------------------
Expand All @@ -46,7 +47,7 @@ def getInternalLinkDict(self, url):
reqBuffId = 'getInternalLinkDict.%s'%url
try: return docelmnt.fetchReqBuff(reqBuffId)
except: pass
request = self.REQUEST
request = self.get('REQUEST', standard.create_headless_http_request())
d = {}
# Params.
anchor = ''
Expand Down Expand Up @@ -87,7 +88,7 @@ def getInternalLinkDict(self, url):
# getInternalLinkUrl:
# ------------------------------------------------------------------------------
def getInternalLinkUrl(self, url, ob):
request = self.REQUEST
request = self.get('REQUEST', standard.create_headless_http_request())
if ob is None:
index_html = './index_%s.html?error_type=NotFound&op=not_found&url=%s'%(request.get('lang', self.getPrimaryLanguage()), str(url))
else:
Expand Down Expand Up @@ -388,6 +389,7 @@ def findObject(self, url):
# Resolves internal/external links and returns Object.
# ----------------------------------------------------------------------------
def getLinkObj(self, url, REQUEST=None):
request = self.get('REQUEST', standard.create_headless_http_request())
ob = None
if isInternalLink(url):
# Params.
Expand Down Expand Up @@ -425,7 +427,6 @@ def getLinkObj(self, url, REQUEST=None):
# Prepare request
ids = self.getPhysicalPath()
if ob is not None and ob.id not in ids:
request = self.REQUEST
ob.set_request_context(request, ref_params)
return ob

Expand Down
Loading

0 comments on commit ced8fb7

Please sign in to comment.