Package buildbot :: Package monkeypatches :: Module bug5079
[frames] | no frames]

Source Code for Module buildbot.monkeypatches.bug5079

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  from twisted.spread import pb 
17  from twisted.python import log 
18  from twisted.spread.interfaces import IJellyable 
19   
20 -def patch():
21 log.msg("Applying patch for http://twistedmatrix.com/trac/ticket/5079") 22 if not hasattr(pb, '_JellyableAvatarMixin'): 23 log.msg("..patch not applicable; please file a bug at buildbot.net") 24 else: 25 pb._JellyableAvatarMixin._cbLogin = _fixed_cbLogin
26
27 -def _fixed_cbLogin(self, (interface, avatar, logout)):
28 """ 29 Ensure that the avatar to be returned to the client is jellyable and 30 set up disconnection notification to call the realm's logout object. 31 """ 32 if not IJellyable.providedBy(avatar): 33 avatar = pb.AsReferenceable(avatar, "perspective") 34 35 puid = avatar.processUniqueID() 36 37 # only call logout once, whether the connection is dropped (disconnect) 38 # or a logout occurs (cleanup), and be careful to drop the reference to 39 # it in either case 40 logout = [ logout ] 41 def maybeLogout(): 42 if not logout: return 43 fn = logout[0] 44 del logout[0] 45 fn()
46 self.broker._localCleanup[puid] = maybeLogout 47 self.broker.notifyOnDisconnect(maybeLogout) 48 49 return avatar 50