[Zope] A question on how external methods reference modules

Goldthwaite, Joe invalid at bar-s.com
Sat Dec 6 17:13:31 EST 2003


I've gotten my external module working but It has one little hassle I've been trying to get around.  If I make a change to the module, I have to go back to the management screen -> External method name and click on the Save Changes button.  It looks like this brings the changes into Zope.  Well, I had the bright idea of linking to a stub function that doesn't change and then have the stub function call the real function that's imported.  I figured I could then modify my method without re-loading it into Zope.

I basically created two modules. In module1.py I have my stub function that chains to module2.py.

module1.py

   import module2

   def ReturnData():
      """Return some test data"""
      return module2.GetTheData()

module2.py

   def GetTheData():
      """Return the actual data"""
      return """the actual data"""

I can run this in python and it works.  After the import module2, I can do a dir on the module2 namespace and I see "GetTheData" as one of the items in the list.  When I add module1->ReturnData to the external module in Zope and execute it, I get the error "module 'mytest' module has no attribute 'GetTheData'".
If I modify ReturnData to this;

   import module2
   def ReturnData():
	"""Return some test data"""
      return dir(module2)

the string returned does not show my "GetTheData" function in the list.  I was getting an error that 'module2' wasn't found so I had to append it's path using the sys.path.append function.  Now I'm not getting an error so I think it's finding module2 but it doesn't seem to be finding the function.  I'm confused.  Can anyone explain what's going on?

As a second part of the question, will this allow me to modify the external modules without re-loading them into Zope?




Property of Bar-S Foods. This message is intended only for the use of the Addressee and may contain information that is PRIVILEGED and CONFIDENTIAL.  If you are not the intended recipient, dissemination of this communication is prohibited.  If you have received this communication in error, please erase all copies of the message and its attachments and notify us immediately at 602.264.7272 or postmaster at bar-s.com.




More information about the Zope mailing list