RE: [Zope] RE: ZopeProfiler issue (found root cause)
Pascal Peregrina wrote at 2005-6-27 20:50 +0200: >Well, what about : > >try: >p= gP() >except: >return > >;) > It travels to your server. It might even get a return value (in case, it is a Zope server) but not necessarily what we expect. I hate unrestricted "try: ... except: ...". They often tend to obscure bugs that should be revealed. They are unsafe when persistent objects are affected. >I will test your patch, not sure about the >+s_class = getattr(s, '__class__', None) >+gpp_class = getattr(s, '__class__', None) The second is definitely wrong. The "s" needs to be "gP". The 3 lines should check whether "s" and "s.getPhysicalPath" have the same class (as is the case when "s" is an "xmlrpclib._Method"). -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] RE: ZopeProfiler issue (found root cause)
Well, what about : try: p= gP() except: return ;) I will test your patch, not sure about the +s_class = getattr(s, '__class__', None) +gpp_class = getattr(s, '__class__', None) in your patch... Pascal -Message d'origine- De : Dieter Maurer [mailto:[EMAIL PROTECTED] Envoyé : lundi 27 juin 2005 20:00 À : Pascal Peregrina Cc : 'zope@zope.org'; Paul Chudleigh Objet : Re: [Zope] RE: ZopeProfiler issue (found root cause) Pascal Peregrina wrote at 2005-6-27 11:53 +0200: >I just finished reading xmlrpclib.py and ZopeProfiler code. > >Here is the root cause of the issue : > >In my code : > getattr(ServerProxy(self.url),self.rpc_method_expr) returns an >xmlrpclib._Method object > >Then ZopeProfiler calls >ZopeProfiler.ZopeProfiler.getHLFuncId(self,fn,frame), which contains: >gP= getattr(s,'getPhysicalPath',None) > >So this calls xmlrpclib._Method.__getattr__, which is: >def __getattr__(self, name): >return _Method(self.__send, "%s.%s" % (self.__name, name)) > >So this returns another xmlrpclib._Method object for a "getPhysicalPath" RPC >method > >Because gP is not None, ZopeProfiler then does : >p= gP() > >And this makes an RPC method call on the service, and of course raises an >Exception ! Nice analysis! >So for my tests I hacked xmlrpclib._Method.__getattr__ to return None for >'getPhysicalPath' : >def __getattr__(self, name): >if name=='getPhysicalPath': >return None >return _Method(self.__send, "%s.%s" % (self.__name, name)) You can do this easier: from xmlrpclib import _Method _Method.getPhysicalPath = None Of course, any way, you will loose the possibility to call "getPhysicalPath" via "XML-RPC". > >But a real fix will be needed on ZopeProfiler ! Try the attached patch. -- Dieter ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ** ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] RE: ZopeProfiler issue (found root cause)
Pascal Peregrina wrote at 2005-6-27 11:53 +0200: >I just finished reading xmlrpclib.py and ZopeProfiler code. > >Here is the root cause of the issue : > >In my code : > getattr(ServerProxy(self.url),self.rpc_method_expr) returns an >xmlrpclib._Method object > >Then ZopeProfiler calls >ZopeProfiler.ZopeProfiler.getHLFuncId(self,fn,frame), which contains: >gP= getattr(s,'getPhysicalPath',None) > >So this calls xmlrpclib._Method.__getattr__, which is: >def __getattr__(self, name): >return _Method(self.__send, "%s.%s" % (self.__name, name)) > >So this returns another xmlrpclib._Method object for a "getPhysicalPath" RPC >method > >Because gP is not None, ZopeProfiler then does : >p= gP() > >And this makes an RPC method call on the service, and of course raises an >Exception ! Nice analysis! >So for my tests I hacked xmlrpclib._Method.__getattr__ to return None for >'getPhysicalPath' : >def __getattr__(self, name): >if name=='getPhysicalPath': >return None >return _Method(self.__send, "%s.%s" % (self.__name, name)) You can do this easier: from xmlrpclib import _Method _Method.getPhysicalPath = None Of course, any way, you will loose the possibility to call "getPhysicalPath" via "XML-RPC". > >But a real fix will be needed on ZopeProfiler ! Try the attached patch. -- Dieter --- ZopeProfiler.py~ 2005-03-26 11:09:23.0 +0100 +++ ZopeProfiler.py 2005-06-27 19:53:31.0 +0200 @@ -379,6 +379,17 @@ s= l.get('self') gP= getattr(s,'getPhysicalPath',None) if gP is None: return +# Try to work around a problem with funny classes returning +# instances of itself for "getPhysicalPath". +# "xmlrpclib._Method" is such a funny class +# Problem reported by "[EMAIL PROTECTED]" +# +# Note that a clean fix would require interfaces with +# a specific interface indicating that "getPhysicalPath" is +# the method we expect. +s_class = getattr(s, '__class__', None) +gpp_class = getattr(s, '__class__', None) +if s_class is not None and s_class is gpp_class: return p= gP() if type(p) is StringType: fi= p else: fi= '/'.join(p) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )