[Twisted-Python] (no subject)

from twisted.spread import pb from twisted.internet import passport, main class ControlPanelPerspective(pb.Perspective): def perspective_shutdown(self): main.shutDown() def perspective_save(self, name=''): import __main__ __main__.application.save(name) class ControlPanelService(pb.Service): def getPerspectiveNamed(self, name): return ControlPanelPerspective("any", self) if __name__ == '__main__': import control_panel from twisted.internet.main import Application app = Application("control_panel") i = passport.Identity("guest", app) i.setPassword("guest") app.authorizer.addIdentity(i) bf = pb.BrokerFactory(app) svc = control_panel.ControlPanelService("control_panel", app) i.addKeyForPerspective(svc.getPerspectiveNamed('any')) app.listenOn(pb.portno, bf) app.save("start")
------------------------------------------------------------<
----------------- pbshutdown.py -----------------------------<
# Twisted, the Framework of Your Internet # Copyright (C) 2001 Matthew W. Lefkowitz # # This library is free software; you can redistribute it and/or # modify it under the terms of version 2.1 of the GNU Lesser General Public # License as published by the Free Software Foundation. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from twisted.spread import pb from twisted.internet import tcp, main def failure(error): print "Failure...",error main.shutDown() def disconnected(): print "disconnected." main.shutDown() def connected(perspective): perspective.shutdown(pberrback=main.shutDown, pbcallback=main.shutDown) print "connected." def preConnected(identity): identity.attach("control_panel", "any", None, pbcallback=connected, pberrback=failure) # run a client b = pb.Broker() b.requestIdentity("guest", # username "guest", # password callback = preConnected, errback = failure) tcp.Client("localhost",pb.portno,b) main.run()
------------------------------------------------------------<
from twisted.spread import pb from twisted.internet import tcp, main def failure(error): print "Failure...",error main.shutDown() def disconnected(): print "disconnected." main.shutDown() def connected(perspective): perspective.save('pbservice', pberrback=main.shutDown, pbcallback=main.shutDown) print "connected." def preConnected(identity): identity.attach("control_panel", "any", None, pbcallback=connected, pberrback=failure) # run a client b = pb.Broker() b.requestIdentity("guest", # username "guest", # password callback = preConnected, errback = failure) tcp.Client("localhost",pb.portno,b) main.run()
------------------------------------------------------------<
-- The Official Moshe Zadka FAQ: http://moshez.geek The Official Moshe Zadka FAQ For Dummies: http://moshez.org Read the FAQ

Hmm. Looks like a lot of code replicated between pbshutdown and pbsave. Should we have a 'connect and send a method call' utility method? -- ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph

On Sat, 22 Sep 2001, Glyph Lefkowitz <glyph@twistedmatrix.com> wrote:
Hmm. Looks like a lot of code replicated between pbshutdown and pbsave. Should we have a 'connect and send a method call' utility method?
Perhaps. I mainly sent this out as a proof of concept for what can be done, not as production-grade stuff. -- The Official Moshe Zadka FAQ: http://moshez.geek The Official Moshe Zadka FAQ For Dummies: http://moshez.org Read the FAQ

Hmm. Looks like a lot of code replicated between pbshutdown and pbsave. Should we have a 'connect and send a method call' utility method? -- ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph

On Sat, 22 Sep 2001, Glyph Lefkowitz <glyph@twistedmatrix.com> wrote:
Hmm. Looks like a lot of code replicated between pbshutdown and pbsave. Should we have a 'connect and send a method call' utility method?
Perhaps. I mainly sent this out as a proof of concept for what can be done, not as production-grade stuff. -- The Official Moshe Zadka FAQ: http://moshez.geek The Official Moshe Zadka FAQ For Dummies: http://moshez.org Read the FAQ
participants (2)
-
Glyph Lefkowitz
-
Moshe Zadka