From b4457dc3074d0ba06632729105c7519185aaaabc Mon Sep 17 00:00:00 2001 From: zmsbot Date: Mon, 18 Sep 2023 22:29:13 +0200 Subject: [PATCH] REST-API: avoid heterolingual titlealt reset Ref: https://github.com/idasm-unibe-ch/unibe-cms/issues/394 --- Products/zms/rest_api.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Products/zms/rest_api.py b/Products/zms/rest_api.py index 1a58f1475..e2b0d6de9 100644 --- a/Products/zms/rest_api.py +++ b/Products/zms/rest_api.py @@ -126,9 +126,11 @@ def get_attrs(node): if metaobj_attr['multilang']: for lang in langs: request.set('lang',lang) - data[id if monolang else '%s_%s'%(id,lang)] = get_attr(node,id) + if get_attr(node,id): + data[id if monolang else '%s_%s'%(id,lang)] = get_attr(node,id) else: - data[id] = get_attr(node,id) + if get_attr(node,id): + data[id] = get_attr(node,id) #print("data",data) return data @@ -142,7 +144,7 @@ def __init__(self, context=None, TraversalRequest=None): if context and TraversalRequest: self.context = context self.method = TraversalRequest['REQUEST_METHOD'] - self.path_to_handle = copy.copy(TraversalRequest['path_to_handle']) + self.path_to_handle = copy.copy(TraversalRequest['path_to_handle']) self.ids = [x for x in self.path_to_handle if x != '++rest_api'] # remove ++rest_api as first element while self.ids: id = self.ids[0] @@ -190,7 +192,7 @@ def __call__(self, REQUEST=None, **kw): REQUEST.RESPONSE.setHeader('Content-Type',decoration['content_type']) return json.dumps(data) return None - + @api(tag="zmsindex", pattern="/zmsindex", content_type="application/json") def zmsindex(self, context): request = _get_request(context) @@ -257,4 +259,4 @@ def get_child_nodes(self, context): def get_tree_nodes(self, context): request = _get_request(context) nodes = context.getTreeNodes(request) - return [get_attrs(x) for x in nodes] \ No newline at end of file + return [get_attrs(x) for x in nodes]