@@ -520,13 +520,25 @@ def _create_cadf_event(self, project, res_spec, res_id, res_parent_id,
520
520
if not action :
521
521
return None
522
522
523
+ # Try to get project_id from request headers
523
524
project_id = request .environ .get ('HTTP_X_PROJECT_ID' )
524
- # If project_id is undefined, look for another variable. This is
525
- # added specific to catching delete events from Neutron
525
+
526
+ # If no project_id found, try to get it from the request context
526
527
if project_id is None :
528
+ # Get the adhoc attributes from the request environment
527
529
adhoc_attrs = request .environ .get ('webob.adhoc_attrs' , {})
528
- context = adhoc_attrs .get ('context' , {})
529
- original_resources = context .get ('original_resources' , [])
530
+
531
+ # Get the context - could be dict or RequestContext object
532
+ context = adhoc_attrs .get ('context' )
533
+
534
+ # 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' ):
539
+ original_resources = context .original_resources
540
+
541
+ # If we found original_resources and it's a list, get project_id
530
542
if original_resources and isinstance (original_resources , list ):
531
543
first_resource = original_resources [0 ]
532
544
if isinstance (first_resource , dict ):
0 commit comments