[Twisted-Python] Deprecation consternation
I understand that the way the authorizer machinery is assembled into twisted seems to be morphing (and not completely propagated into other twisted components yet, hence all the deprecation messages when running the unit tests), and I was trying to see if I could do things properly (the new way) in my code -- but not successfully yet, I guess, because when running this (shamelessly purloined and modified from the pgquoter.py example): from twisted.spread import pb from pdmengine import BasePdmEngine class PdmClient(pb.Perspective): def perspective_getProductsByProject(self): return self.service.BasePdmEngine.getProductsByProject(project) class PdmPBService(pb.Service): def __init__(self, engine, serviceName, authorizer, application=None): pb.Service.__init__(self, serviceName, authorizer, application) perspectiveClass = PdmClient --- ... with mktap I still get: /home/waterbug/sandbox/TwistedPlugins/TwistedPdm/pdmpb.py:10: DeprecationWarning: You have to pass an authorizer separately from an application now. pb.Service.__init__(self, serviceName, authorizer, application) /usr/local/lib/python2.2/site-packages/twisted/cred/service.py:72: DeprecationWarning: Application.authorizer attribute is deprecated, use Service.authorizer instead authorizer = sp.authorizer /usr/local/lib/python2.2/site-packages/twisted/spread/pb.py:972: DeprecationWarning: Application.authorizer attribute is deprecated, use Service.authorizer instead auth = auth.authorizer Saving pgpdm application to pgpdm.tap... Saved. --- I understand the second 2 warnings, which are internal to twisted, but I'm puzzled by the first one, which refers to this line: pb.Service.__init__(self, serviceName, authorizer, application) ^^^^^^^^^^ I thought I _was_ passing an authorizer separately! Suggestions? What should the syntax be under the new authorizer regime? tnx! -- Steve. Stephen C. Waterbury http://misspiggy.gsfc.nasa.gov/people/waterbug.html
On Fri, 16 Aug 2002 14:45:34 -0400, Steve Waterbury <waterbug@beeblebrox.gsfc.nasa.gov> wrote:
I understand that the way the authorizer machinery is assembled into twisted seems to be morphing (and not completely propagated into other twisted components yet, hence all the deprecation messages when running the unit tests), and I was trying to see if I could do things properly (the new way) in my code -- but not successfully yet, I guess, because when running this (shamelessly purloined and modified from the pgquoter.py example):
Morph*ed*, thankfully -- I don't forsee any future changes at this point, besides eventually cleaning up these internal deprecation warnings and eventually removing the backwards compatibility code. Unless I made a mistake, of course, which is impossible.
I understand the second 2 warnings, which are internal to twisted, but I'm puzzled by the first one, which refers to this line:
pb.Service.__init__(self, serviceName, authorizer, application)
I thought I _was_ passing an authorizer separately!
Heh. Perhaps the warning should be a bit clearer: def __init__(self, serviceName, serviceParent=None, authorizer=None, application=None):
Suggestions? What should the syntax be under the new authorizer regime?
You're just passing the authorizer and application in the reverse order :-). Other than that you're OK with the "new regime". You should also see one of the other warnings go away. It looks like your "application" is None in this example, though, just at a glance through the twisted.cred.service code that's spitting out this warning. -- | <`'> | Glyph Lefkowitz: Traveling Sorcerer | | < _/ > | Lead Developer, the Twisted project | | < ___/ > | http://www.twistedmatrix.com |
participants (2)
-
Glyph Lefkowitz -
Steve Waterbury