Skip to content

Commit 98b5687

Browse files
committed
use duck typing, more pythonic
1 parent 3621936 commit 98b5687

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

auditmiddleware/_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,14 @@ def _create_cadf_event(self, project, res_spec, res_id, res_parent_id,
529529
adhoc_attrs = request.environ.get('webob.adhoc_attrs', {})
530530

531531
# Get the context - could be dict or RequestContext object
532-
context = adhoc_attrs.get('context')
532+
context = adhoc_attrs.get('context', {})
533533

534+
original_resources = []
534535
# Handle both dict and RequestContext object types
535-
original_resources = None
536-
if isinstance(context, dict):
537-
original_resources = context.get('original_resources', [])
538-
elif hasattr(context, 'original_resources'):
536+
if hasattr(context, 'original_resources'):
539537
original_resources = context.original_resources
538+
else:
539+
original_resources = context.get('original_resources', [])
540540

541541
# If we found original_resources and it's a list, get project_id
542542
if original_resources and isinstance(original_resources, list):

0 commit comments

Comments
 (0)