Skip to content

Commit

Permalink
More options for ZMS-init (#366)
Browse files Browse the repository at this point in the history
Replaced xml-pack of base-theme by git-optimized conf-data
  • Loading branch information
drfho authored Feb 17, 2025
1 parent 2a8ea56 commit 2a6f7db
Show file tree
Hide file tree
Showing 41 changed files with 316 additions and 2,374 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
4 changes: 2 additions & 2 deletions Products/zms/ZMSRepositoryManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def readRepository(self, provider):


"""
Commit ZODB to repository.
Export: Commit ZODB to repository.
"""
def commitChanges(self, ids):
standard.writeLog(self,"[commitChanges]: ids=%s"%str(ids))
Expand Down Expand Up @@ -191,7 +191,7 @@ def commitChanges(self, ids):
return success,failure

"""
Update ZODB from repository.
Import: Update ZODB from repository.
"""
def updateChanges(self, ids, override=False):
standard.writeLog(self,"[updateChanges]: ids=%s"%str(ids))
Expand Down
2 changes: 1 addition & 1 deletion Products/zms/ZMSZCatalogAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __init__(self):

def ensure_zcatalog_connector_is_initialized(self):
root = self.getRootElement()
if 'zcatalog_connector' not in root.getMetaobjIds():
if 'zcatalog_connector' not in root.getMetaobjIds() and self.REQUEST.get('zcatalog_init', 1) == 1:
_confmanager.initConf(root, 'conf:com.zms.catalog.zcatalog')

############################################################################
Expand Down
53 changes: 50 additions & 3 deletions Products/zms/_confmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,38 @@ 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}.
In case of C{conf:}-prefix, the filename is expected to be in the format
C{conf:container_id/package-id}, e.g. C{conf:metaobj_manager/com.zms.foundation.theme};
Example: C{conf:metaobj_manager/com.zms.foundation.theme/theme_zms_base} will match to path
{conf:metaobj_manager/com.zms.foundation.theme}.
This means only the 1st level of the naming hierarchy (in case of metaobj_manager
mostly the package-id is used to match the pattern). Nested packages are always
imported as a whole.
@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):
label = files[filename]
if fnmatch(label,'*%s-*'%pattern):
if len(pattern.split('/')) > 2 and fnmatch(label,'*%s-*'%'/'.join(pattern.split('/')[1:-1])) or fnmatch(label,'*%s-*'%pattern):
standard.writeBlock( self, '[initConf]: filename='+filename)
if filename.endswith('.zip'):
self.importConfPackage(filename)
Expand Down Expand Up @@ -148,7 +172,6 @@ class ConfManager(
# ConfManager.importConfPackage:
# --------------------------------------------------------------------------
def importConfPackage(self, file):

if isinstance(file, str):
if file.startswith('http://') or file.startswith('https://'):
file = StringIO( self.http_import(file))
Expand All @@ -168,6 +191,7 @@ def getConfXmlFile(self, file):
filename = file['filename']
xml = file['data']
xmlfile = StringIO( xml)
# Get conf not from a xml-package but from the ZMS-conf folder.
elif isinstance(file, str) and (file.startswith('conf:')):
filename = file[file.find(':')+1:]
basepath = repositoryutil.get_system_conf_basepath()
Expand All @@ -192,6 +216,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 @@ -240,7 +281,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 distribution 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{ZPublisher.HTTPResponse}, optional.
@param RESPONSE: C{ZPublisher.HTTPRequest}, optional, if provided, the method will return a JSON response.
"""
filenames = {}
# Import-Folder.
Expand Down
16 changes: 10 additions & 6 deletions Products/zms/_xmllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,16 @@ def toCdata(self, s, xhtml=False):

# Return Text in CDATA.
elif s is not None:
if isinstance(s, bytes):
s = s.decode('utf-8')
# Hack for invalid characters
s = s.replace(chr(30), '')
# Hack for nested CDATA
s = re.compile(r'\<\!\[CDATA\[(.*?)\]\]\>').sub(r'<!{CDATA{\1}}>', s)
try:
if isinstance(s, bytes):
s = s.decode('utf-8')
# Hack for invalid characters
s = s.replace(chr(30), '')
# Hack for nested CDATA
s = re.compile(r'\<\!\[CDATA\[(.*?)\]\]\>').sub(r'<!{CDATA{\1}}>', s)
except:
standard.writeBlock(self, "[toCdata]: WARNING - Cannot create file/image object from binary data")
pass
# Wrap with CDATA
rtn = '<![CDATA[%s]]>'%s

Expand Down
4 changes: 2 additions & 2 deletions Products/zms/apidocs/theme/footer.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<footer xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1" class="navbar navbar-default">

<meta name="pydoctor-template-version" content="2" />
<div class="container">
<meta name="pydoctor-template-version" content="3" />
<div class="container-fluid">
<a href="index.html">API Documentation</a> for <t:slot name="project" />,
generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a>
<!-- t:slot name="pydoctor_version" /> at <t:slot name="buildtime" / -->.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class com_zms_calendar:
package = ""

# Revision
revision = "0.0.5"
revision = "0.0.6"

# Type
type = "ZMSPackage"
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class calendar_items:
package = "com.zms.calendar"

# Revision
revision = "0.0.5"
revision = "0.0.6"

# Type
type = "ZMSRecordSet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ class com_zms_foundation_theme:
python-representation of com.zms.foundation.theme
"""

# Access
access = {"delete_custom":""
,"delete_deny":[]
,"insert_custom":""
,"insert_deny":[]}

# Enabled
enabled = 1
enabled = 0

# Id
id = "com.zms.foundation.theme"
Expand All @@ -16,7 +22,7 @@ class com_zms_foundation_theme:
package = ""

# Revision
revision = "5.0.1"
revision = "5.1.0"

# Type
type = "ZMSPackage"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class skin_zms5_base:
class zms_theme_basic:
"""
python-representation of skin_zms5_base
python-representation of zms_theme_basic
"""

# Access
Expand All @@ -13,16 +13,16 @@ class skin_zms5_base:
enabled = 0

# Id
id = "skin_zms5_base"
id = "zms_theme_basic"

# Name
name = "skin_zms5_base"
name = "zms_theme_basic"

# Package
package = ""
package = "com.zms.foundation.theme"

# Revision
revision = "5.0.2"
revision = "5.0.3"

# Type
type = "ZMSLibrary"
Expand All @@ -38,92 +38,92 @@ class Attrs:
,"repetitive":0
,"type":"resource"}

skin_zms5_base_standard_html = {"default":""
,"id":"skin_zms5_base/standard_html"
zms_theme_basic_standard_html = {"default":""
,"id":"zms_theme_basic/standard_html"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"standard_html"
,"repetitive":0
,"type":"Page Template"}

skin_zms5_base_pageelements = {"default":""
,"id":"skin_zms5_base/pageelements"
zms_theme_basic_pageelements = {"default":""
,"id":"zms_theme_basic/pageelements"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"pageelements"
,"repetitive":0
,"type":"Page Template"}

skin_zms5_base_faviconico = {"default":""
,"id":"skin_zms5_base/favicon.ico"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"favicon.ico"
,"repetitive":0
,"type":"Image"}

skin_zms5_base_common_added_webcss = {"default":""
,"id":"skin_zms5_base/common/added/web.css"
zms_theme_basic_common_added_webcss = {"default":""
,"id":"zms_theme_basic/common/added/web.css"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"web.css"
,"repetitive":0
,"type":"File"}

skin_zms5_base_common_added_webjs = {"default":""
,"id":"skin_zms5_base/common/added/web.js"
zms_theme_basic_common_added_webjs = {"default":""
,"id":"zms_theme_basic/common/added/web.js"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"web.js"
,"repetitive":0
,"type":"File"}

skin_zms5_base_common_added_zmicss = {"default":""
,"id":"skin_zms5_base/common/added/zmi.css"
zms_theme_basic_common_added_zmicss = {"default":""
,"id":"zms_theme_basic/common/added/zmi.css"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"zmi.css"
,"repetitive":0
,"type":"File"}

skin_zms5_base_common_added_zmijs = {"default":""
,"id":"skin_zms5_base/common/added/zmi.js"
zms_theme_basic_common_added_zmijs = {"default":""
,"id":"zms_theme_basic/common/added/zmi.js"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"zmi.js"
,"repetitive":0
,"type":"File"}

skin_zms5_base_common_css_stylecss = {"default":""
,"id":"skin_zms5_base/common/css/style.css"
zms_theme_basic_common_css_stylecss = {"default":""
,"id":"zms_theme_basic/common/css/style.css"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"style.css"
,"repetitive":0
,"type":"File"}

skin_zms5_base_common_img_zmslogosvg = {"default":""
,"id":"skin_zms5_base/common/img/zmslogo.svg"
zms_theme_basic_common_webdesign_custom_zmsdemocss = {"default":""
,"id":"zms_theme_basic/common/webdesign/custom_zmsdemo.css"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"custom_zmsdemo.css"
,"repetitive":0
,"type":"File"}

zms_theme_basic_common_img_zmslogosvg = {"default":""
,"id":"zms_theme_basic/common/img/zmslogo.svg"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"zmslogo.svg"
,"repetitive":0
,"type":"Image"}
,"type":"File"}

skin_zms5_base_common_webdesign_custom_zmsdemocss = {"default":""
,"id":"skin_zms5_base/common/webdesign/custom_zmsdemo.css"
zms_theme_basic_common_img_faviconico = {"default":""
,"id":"zms_theme_basic/common/img/favicon.ico"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"custom_zmsdemo.css"
,"name":"favicon.ico"
,"repetitive":0
,"type":"File"}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
--zms_header_bg:#ffffff !important;
--zms_header_main_text_color:#333333;
--zms_header_dropdown_text_color:#333333;
--zms_logo: url('skin_zms5_base/common/img/zmslogo.svg');
--zms_logo: url('theme_zms5_base/common/img/zmslogo.svg');
--zms_card_bg:white;
--zms_card_shadow:0 0 2rem rgba(0,0,0,0.2);
--zms_card_delimiter_border:1px dotted #333;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CSSLib:
name = "CSSLib"

# Package
package = "com.zms.foundation.theme"
package = "com.zms.foundation.theming"

# Revision
revision = "5.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class ZMSTheme:
id = "ZMSTheme"

# Name
name = "ZMSTheme"
name = "ZMSTheme-Switch"

# Package
package = "com.zms.foundation.theme"
package = "com.zms.foundation.theming"

# Revision
revision = "5.0.1"
Expand Down
Loading

0 comments on commit 2a6f7db

Please sign in to comment.