launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04454
lp:~allenap/launchpad/dsd-base-view-dont-modify-globals-bug-809985 into lp:launchpad
Gavin Panella has proposed merging lp:~allenap/launchpad/dsd-base-view-dont-modify-globals-bug-809985 into lp:launchpad with lp:~allenap/launchpad/selected-differences-vocab-bug-817408 as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #809985 in Launchpad itself: "DistroSeriesDifferenceBaseView modifies shared objects"
https://bugs.launchpad.net/launchpad/+bug/809985
For more details, see:
https://code.launchpad.net/~allenap/launchpad/dsd-base-view-dont-modify-globals-bug-809985/+merge/70076
Jump through hoops to avoid updating a global in a view, which I hope we agree would be a bad thing :)
--
https://code.launchpad.net/~allenap/launchpad/dsd-base-view-dont-modify-globals-bug-809985/+merge/70076
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/dsd-base-view-dont-modify-globals-bug-809985 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py 2011-08-01 20:31:33 +0000
+++ lib/lp/registry/browser/distroseries.py 2011-08-01 20:31:35 +0000
@@ -828,9 +828,18 @@
super(DistroSeriesDifferenceBaseView, self).initialize()
def initialize_sync_label(self, label):
- # XXX: GavinPanella 2011-07-13 bug=809985: Good thing the app servers
- # are running single threaded...
- self.__class__.actions.byname['actions.sync'].label = label
+ # Owing to the design of Action/Actions in zope.formlib.form - actions
+ # is actually a descriptor that copies itself and its actions when
+ # accessed - this has the effect of making a shallow copy of the sync
+ # action which we can modify.
+ actions = self.actions
+ sync_action = next(
+ action for action in actions if action.name == "sync")
+ sync_action.label = label
+ # Mask the actions descriptor with an instance variable.
+ self.actions = actions.__class__(
+ *((sync_action if action.name == "sync" else action)
+ for action in actions))
@property
def label(self):