Skip to content

Commit

Permalink
REST-API: avoid heterolingual titlealt reset (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho authored Sep 29, 2023
1 parent 97aa209 commit f057f41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Products/zms/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
return [get_attrs(x) for x in nodes]
2 changes: 1 addition & 1 deletion Products/zms/zmsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f057f41

Please sign in to comment.