Skip to content

Commit

Permalink
Merge branch 'main' into cekk_path2uid_handle_aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli authored Dec 17, 2024
2 parents 69e6c61 + 93ceb88 commit 807ca7b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]
jobs:
build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand Down
1 change: 1 addition & 0 deletions news/1851.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Optimized performance of DexterityObjectPrimaryFieldTarget adapter. @maurits
31 changes: 17 additions & 14 deletions src/plone/restapi/serializer/dxcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,26 @@ def __init__(self, context, request):

def __call__(self):
primary_field_name = self.get_primary_field_name()
if not primary_field_name:
return
for schema in iterSchemata(self.context):
read_permissions = mergedTaggedValueDict(schema, READ_PERMISSIONS_KEY)

for name, field in getFields(schema).items():
if not self.check_permission(read_permissions.get(name), self.context):
continue

if name != primary_field_name:
continue

target_adapter = queryMultiAdapter(
(field, self.context, self.request), IPrimaryFieldTarget
)
if target_adapter:
target = target_adapter()
if target:
return target
field = getFields(schema).get(primary_field_name)
if field is None:
continue
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 807ca7b

Please sign in to comment.