From f057f413246f832e48bd172a8d542c3e32f36807 Mon Sep 17 00:00:00 2001 From: drfho Date: Sat, 30 Sep 2023 00:05:39 +0200 Subject: [PATCH] REST-API: avoid heterolingual titlealt reset (#181) Ref: https://github.com/idasm-unibe-ch/unibe-cms/issues/394 --- Products/zms/rest_api.py | 11 ++++++----- Products/zms/zmsobject.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Products/zms/rest_api.py b/Products/zms/rest_api.py index 1a58f1475..d4e81a23d 100644 --- a/Products/zms/rest_api.py +++ b/Products/zms/rest_api.py @@ -118,18 +118,19 @@ def get_attrs(node): data['home_id'] = node.getHome().id data['level'] = node.getLevel() data['restricted'] = node.hasRestrictedAccess() + general_keys = data.keys() obj_attrs = node.getObjAttrs() metaobj_attrs = node.getMetaobjManager().getMetaobjAttrs(node.meta_id) for metaobj_attr in metaobj_attrs: id = metaobj_attr['id'] - if id in obj_attrs: + if id in obj_attrs and not id in general_keys: 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) else: data[id] = get_attr(node,id) - #print("data",data) + # print("data",data) return data @@ -142,7 +143,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 +191,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 +258,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] diff --git a/Products/zms/zmsobject.py b/Products/zms/zmsobject.py index 827a3d4bb..8e480552a 100644 --- a/Products/zms/zmsobject.py +++ b/Products/zms/zmsobject.py @@ -373,7 +373,7 @@ def getTitle( self, REQUEST): # ZMSObject.getTitlealt # -------------------------------------------------------------------------- def getTitlealt( self, REQUEST): - s = self.getObjProperty('titlealt', REQUEST) + s = self.getObjProperty('titlealt', REQUEST) or self.getObjProperty('titlealt', {'lang':self.getPrimaryLanguage()}) if not s: s = self.display_type() if not s: