Skip to content

Commit

Permalink
REST-API: avoid heterolingual titlealt reset
Browse files Browse the repository at this point in the history
  • Loading branch information
zmsbot committed Sep 18, 2023
1 parent 786e7d6 commit b4457dc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Products/zms/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
return [get_attrs(x) for x in nodes]

0 comments on commit b4457dc

Please sign in to comment.