Merge ~sylvain-pineau/plainbox:empty_resource into plainbox:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 461bd85fb1c49c0ce54bde3cd8867a604118a2fc
Merged at revision: 491fab08df0c10b9feaee04977910e543d6779aa
Proposed branch: ~sylvain-pineau/plainbox:empty_resource
Merge into: plainbox:master
Diff against target: 13 lines (+3/-0)
1 file modified
plainbox/impl/ctrl.py (+3/-0)
Reviewer Review Type Date Requested Status
Maciej Kisielewski Approve
Review via email: mp+326929@code.launchpad.net

Description of the change

This patch avoids job requirements to fail if one resource object has no records.

Tested with mediacard/sd-preinserted on a system with no snaps installed

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

I like it!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/plainbox/impl/ctrl.py b/plainbox/impl/ctrl.py
index 0ad1a47..ac019fa 100644
--- a/plainbox/impl/ctrl.py
+++ b/plainbox/impl/ctrl.py
@@ -295,6 +295,9 @@ class CheckBoxSessionStateController(ISessionStateController):
295 logger.info(295 logger.info(
296 _("Storing resource record %r: %s"), job.id, resource)296 _("Storing resource record %r: %s"), job.id, resource)
297 new_resource_list.append(resource)297 new_resource_list.append(resource)
298 # Create an empty resource object to properly fail __getattr__ calls
299 if not new_resource_list:
300 new_resource_list = [Resource({})]
298 # Replace any old resources with the new resource list301 # Replace any old resources with the new resource list
299 session_state.set_resource_list(job.id, new_resource_list)302 session_state.set_resource_list(job.id, new_resource_list)
300303

Subscribers

People subscribed via source and target branches