~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/distroseries.py

[r=wgrant][bug=809985] Set the sync action label safely in
 DistroSeriesDifferenceBaseView. In other words,
 don't modify shared global objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
828
828
        super(DistroSeriesDifferenceBaseView, self).initialize()
829
829
 
830
830
    def initialize_sync_label(self, label):
831
 
        # XXX: GavinPanella 2011-07-13 bug=809985: Good thing the app servers
832
 
        # are running single threaded...
833
 
        self.__class__.actions.byname['actions.sync'].label = label
 
831
        # Owing to the design of Action/Actions in zope.formlib.form - actions
 
832
        # is actually a descriptor that copies itself and its actions when
 
833
        # accessed - this has the effect of making a shallow copy of the sync
 
834
        # action which we can modify.
 
835
        actions = self.actions
 
836
        sync_action = next(
 
837
            action for action in actions if action.name == "sync")
 
838
        sync_action.label = label
 
839
        # Mask the actions descriptor with an instance variable.
 
840
        self.actions = actions.__class__(
 
841
            *((sync_action if action.name == "sync" else action)
 
842
              for action in actions))
834
843
 
835
844
    @property
836
845
    def label(self):