[Zope] external methods and pyc files

Richard Jolly r.jolly at bridgelinkit.com
Fri Feb 6 11:18:56 EST 2004


Paul Winkler wrote:

First, thanks for you help and patience.

> On Thu, Feb 05, 2004 at 04:44:06PM +0000, Richard Jolly wrote:
> 
>>It turns out that renaming, via the ZMI, the external methods is not 
>>sufficient. They still get confused. Presumably if I rename the methods 
>>is the py files this would finally eliminate the problem.
> 
> 
> This is very doubtful.

I have to agree - its a thousand times more likely that there is a 
problem with the application code than with Zope.

> The function names in Extentions/*.py should be irrelevant
> to all objects other than the External Method itself.
> When a Zope object calls an external method, it does so by the
> name of the external method in the ZMI.

Yes - again, my unfamiliarity with Zope will show through - but I am 
experiencing very odd behaviour.

I have renamed the methods (changed the ids) within the ZMI, and saved 
the methods to refresh them (and restarted Zope, just to be sure).

(I have no idea if this is relevant, but I can only rename in the ZMI by 
ticking the checkbox of the external method and clicking 'rename'. If I 
try and do it by clicking through to the external method object, 
changing the id and clicking 'save changes' it just doesn't take.)

If the .py files are in the Extensions folder, then this works fine. If, 
however, only the .pyc files are in, then I get the same behaviour as 
before. It appears that the wrong method is called - however perhaps the 
right method (by name) is called, but the wrong code is associated with 
it, because it can't be loaded from the .pyc file or some such. Can the 
reload be silently failing for a pyc file?

These errors are triggered by the call to the second external method 
sharing the same function name that is called. It doesn't matter which 
is called first, but when the second is called, it fails and will 
consistently fail from then on.

There is another wrinkle.

There are two identically named functions in the .py files. One of these 
is unused.

Root
  A/
    methx_strange
      id = methx_strange
      module = foo.py
      name = strange
   B/
    other external methods

foo.py
   def strange

bar.py
   def strange

On occaision bar.py's strange method is called. How can this be?

I'm at a loss to explain this unless somehow the module name is not used.

> At this point, still knowing nothing about your application,
> I wonder if there is another layer of indirection involved
> where the confusion happens. You have two differently-named
> external methods; therefore you can only get the wrong one 
> if you ask for the wrong one; therefore, the error must
> be elsewhere than in the external methods.

Its quite simple, although not well coded.

> Make sure you really understand which objects are calling the 
> external methods and when. Is there one object that decides
> which one to call? Is there a cache manager caching this object?
> Or are there multiple objects that call the ext. methods?

They are called on form submissions, eg action="ext_meth_name". From 
what I can see there is no deliberate caching. The logs 
(DETAILED_LOG_FILE form z2.py) give the post data as 
/folder/ext_meth_name , which seems appropriate.

There are no arguments to the methods (they get their data from 
self.REQUEST).

I'm sure I don't understand half as much as I should. Is there an easy 
way to get all information about the context/caller of an external method?

Info I should have mentioned earlier:
	
Zope Version Zope 2.3.2 (binary release, python 1.5.2, win32-x86)
Python Version 1.5.2 (#0, Jul 30 1999, 09:52:18) [MSC 32 bit (Intel)]
System Platform win32


Thanks very much for your help with this,

-- 
Richard Jolly





More information about the Zope mailing list