Skip to content

Commit

Permalink
added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho committed Feb 14, 2025
1 parent a913f6c commit 0b55dc1
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 21 deletions.
12 changes: 6 additions & 6 deletions Products/zms/IZMSCatalogConnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def search_json(self, REQUEST=None, RESPONSE=None):
def reindex_page(self, uid, page_size, clients=False, fileparsing=True, REQUEST=None, RESPONSE=None):
"""
Reindex page.
@param uid the uid of the page's start-node
@param page-size the page-size
@param clients process clients
@type clients C{Boolean}
@param fileparsing parse files
@type fileparsing C{Boolean}
@param uid: the uid of the page's start-node
@param page_size: the page-size
@param clients: process clients
@type clients: C{Boolean}
@param fileparsing: parse files
@type fileparsing: C{Boolean}
@param REQUEST: the triggering request
@type REQUEST: ZPublisher.HTTPRequest
@return log
Expand Down
44 changes: 42 additions & 2 deletions Products/zms/_confmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,29 @@ def forName(cls, name):
# _confmanager.initConf:
# ------------------------------------------------------------------------------
def initConf(self, pattern):
"""
Initialize a ZMS configuration by importing a set of configuration files
that match a given name pattern, e.g. 'unibern.*'.
The pattern should be in the format C{prefix:pattern}, where actually
only C{pattern} is the part of the filename to match using function fnmatch().
If a matching file is found and it ends with '.zip', it will be imported
as a configuration package. Otherwise, it will be imported as a a single XML
file or - if prefixed with C{conf:} as a set of configuration files from
the ZMS conf-folder.
The full list of available configuration files is aggrgated by the method
L{ConfManager.getConfFiles}.
@param pattern: String-pattern to filter filenames.
@type pattern: C{string}
@return: None
@rtype: C{None}
"""
standard.writeBlock( self, '[initConf]: pattern='+pattern)
prefix = pattern.split(':')[0]
pattern = pattern.split(':')[1]
files = self.getConfFiles()
for filename in files:
if filename.startswith(prefix) and 'theme.default' not in filename:
if filename.startswith(prefix): # and 'theme.default' not in filename:
label = files[filename]
if fnmatch(label,'*%s-*'%pattern):
standard.writeBlock( self, '[initConf]: filename='+filename)
Expand Down Expand Up @@ -193,6 +210,23 @@ def getConfXmlFile(self, file):
# ConfManager.importConf:
# --------------------------------------------------------------------------
def importConf(self, file, syncIfNecessary=True):
"""
Imports configuration from the given file and processes
it in the context according to its filename.
@param file: The path to the configuration file to be imported.
@type file: C{str}
@param syncIfNecessary: Flag indicating whether to synchronize object attributes if necessary. Defaults to True.
@type syncIfNecessary: C{bool}, optional
@return: A message indicating the result of the import operation.
@rtype: C{str}
Notes:
- The method identifies the type of configuration file based on its filename and processes it accordingly.
- Hidden files created by MacOSX (starting with '._') are ignored.
- If the filename contains specific substrings (e.g., '.charfmt.', '.filter.', etc.), the corresponding import method is called.
- If synchronization is necessary and the syncIfNecessary flag is True, the object's attributes are synchronized.
"""
message = ''
syncNecessary = False
filename, xmlfile = self.getConfXmlFile( file)
Expand Down Expand Up @@ -241,7 +275,13 @@ def getPluginIds(self, path=[]):
security.declareProtected('ZMS Administrator', 'getConfFiles')
def getConfFiles(self, pattern=None, REQUEST=None, RESPONSE=None):
"""
ConfManager.getConfFiles
Retrieve configuration files from the ZMS source code:
1. Product/zms/conf: Sets of singular configuration files (repository-manager style, pattern-prefix 'conf:').
2. Product/zms/import: Classical zipped XML packages, e.g. for importing as single file via web-frontend.
@param pattern: string, optional, pattern to filter filenames.
@param REQUEST: C(object), optional.
@param RESPONSE: C(object), optional, if provided, the method will return a JSON response.
"""
filenames = {}
# Import-Folder.
Expand Down
23 changes: 14 additions & 9 deletions Products/zms/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def addZMSCustom(self, meta_id=None, values={}, REQUEST=None):
Public alias for manage_addZMSCustom:
add a custom node of the type designated by meta_id in current context.
@param self: context node
@type self: C{zmsobject.ZMSObject}
@param meta_id: the meta-id / type of the new ZMSObject
@type meta_id: C{str}
@param values: the dictionary of initial attribut-values assigned to the new ZMSObject
Expand Down Expand Up @@ -308,19 +310,22 @@ def set_response_headers_cache(context, request=None, cache_max_age=24*3600, cac
"""
Set default and dynamic cache response headers according to ZMS_CACHE_EXPIRE_DATETIME
which is determined in ObjAttrs.isActive for each page element as the earliest time for invalidation.
I:Usage: Add to standard_html master template, e.g.::
- U{https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#directives}
- U{http://nginx.org/en/docs/http/ngx_http_headers_module.html#expires}
- U{https://github.com/nginxinc/nginx-wiki/blob/master/source/start/topics/examples/x-accel.rst}
Usage: Add to standard_html master template, e.g.::
<tal:block tal:define="
standard modules/Products.zms/standard;
cache_expire python:standard.set_response_headers_cache(this, request, cache_max_age=0, cache_s_maxage=6*3600)">
</tal:block>
@param cache_max_age: seconds the element remains in all caches (public/proxy and private/browser)
@param cache_s_maxage: seconds the element remains in public/proxy cache (value -1 means cache_s_maxage = cache_max_age)
@see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#directives
@see: http://nginx.org/en/docs/http/ngx_http_headers_module.html#expires
@see: https://github.com/nginxinc/nginx-wiki/blob/master/source/start/topics/examples/x-accel.rst
@returns: Tuple of expires date time in GMT as ISO8601 string and the seconds until expiration
@retype: C{tuple}
@return: Tuple of expires date time in GMT as ISO8601 string and the seconds until expiration
@rtype: C{tuple}
"""
if request is not None:
is_preview = request.get('preview', '') == 'preview'
Expand Down Expand Up @@ -359,8 +364,8 @@ def once(key, request):
once per request
@param key: the key
@param request: the request
@returns: Boolean execute once
@retype: C{boolean}
@return: Boolean execute once
@rtype: C{boolean}
"""
req_key = 'f_%s'%key
req_val = request.get(req_key,True)
Expand Down Expand Up @@ -2249,7 +2254,7 @@ def htmldiff(original, changed):
"""
Wrapper for htmldiff2.render_html_diff.
@param original: html-file-0
@type context: C{str}
@type original: C{str}
@param changed: html-file-1
@type changed: C{str}
"""
Expand Down
9 changes: 5 additions & 4 deletions Products/zms/zms.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ def manage_addZMS(self, lang, manage_lang, REQUEST, RESPONSE):

##### Configuration ####

# Initialize catalog adapter / connector.
if REQUEST.get('zcatalog_init', 0)==1:
#-- Search GUI
initContent(obj, 'com.zms.search.content.xml', REQUEST)
# Initialize catalog adapter / connector.
#-- Search GUI: now is part of com.zms.catalog
# initContent(obj, 'com.zms.search.content.xml', REQUEST)
_confmanager.initConf(obj, 'conf:com.zms.catalog.zcatalog')
catalog_adapter = obj.getCatalogAdapter(createIfNotExists=True)
catalog_connector = catalog_adapter.add_connector('zcatalog_connector')
Expand Down Expand Up @@ -603,7 +603,8 @@ def __before_publishing_traverse__(self, object, request):
key ZMS.mode.maintenance=1. The maintenance mode prevents
editing content and returns an error: 503 Service Unavailable.
To show a specific message the Zope object standard_error_message
should be customized, e.g. like this:
should be customized, e.g. like this::
<tal:block
tal:define="
errtype python:options.get('error_type',None);
Expand Down

0 comments on commit 0b55dc1

Please sign in to comment.