Skip to content

Commit

Permalink
Primary field target: get primary_field_name directly instead of iter…
Browse files Browse the repository at this point in the history
…ating over all fields.
  • Loading branch information
mauritsvanrees committed Dec 16, 2024
1 parent 69e2c94 commit db0c975
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/plone/restapi/serializer/dxcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,22 @@ def __call__(self):
for schema in iterSchemata(self.context):
read_permissions = mergedTaggedValueDict(schema, READ_PERMISSIONS_KEY)

for name, field in getFields(schema).items():
if name != primary_field_name:
continue

if not self.check_permission(read_permissions.get(name), self.context):
return

target_adapter = queryMultiAdapter(
(field, self.context, self.request), IPrimaryFieldTarget
)
if not target_adapter:
return
return target_adapter()
field = getFields(schema).get(primary_field_name)
if field is None:
continue
print(primary_field_name)
if not self.check_permission(
read_permissions.get(primary_field_name),
self.context,
):
return

target_adapter = queryMultiAdapter(
(field, self.context, self.request), IPrimaryFieldTarget
)
if not target_adapter:
return
return target_adapter()

def get_primary_field_name(self):
fieldname = None
Expand Down

0 comments on commit db0c975

Please sign in to comment.