[Zope] external method import error (ImportError)...

Eric ewalstad@yahoo.com
Wed, 04 Oct 2000 15:01:53 -0700


Hi,

To summarize: How do I import modules in an External Method's .py file?

I have an external method that points to a .py file that has an import
statement at the top.  The import statement loads another module of mine
(CProject.py).  I've placed both files (pwToxml.py and CProject.py) in the
Zope/Extensions directory.  When I try to create an external method on the
pTox.py file with the following parameters:
ID = pTox
Function Name = pTox
Python Module File = pwToxml
I get the following error:
Error Type: ImportError
Error Value: No module named CProject
Traceback (innermost last):
  File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
  File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 187, in
publish
  File /usr/local/Zope/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
  File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 171, in
publish
  File /usr/local/Zope/lib/python/ZPublisher/mapply.py, line 160, in mapply
    (Object: manage_addExternalMethod)
  File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 112, in
call_object
    (Object: manage_addExternalMethod)
  File /usr/local/Zope/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 130, in manage_addExternalMethod
  File /usr/local/Zope/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 178, in __init__
    (Object: pTox)
  File /usr/local/Zope/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 201, in manage_edit
    (Object: pTox)
  File /usr/local/Zope/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 210, in getFunction
    (Object: pTox)
  File /usr/local/Zope/lib/python/App/Extensions.py, line 217, in getObject
    (Info: ('/usr/local/Zope/Extensions/pwToxml.py', 'pwToxml'))
  File /usr/local/Zope/Extensions/pwToxml.py, line 1, in ?
ImportError: (see above)

I checked the sys.path for my Python installation and placed the CProject.py
file there, but I still get the same error.

Here's the top of my pwToxml.py file:

import CProject, string

def pTox(self, REQUEST):
    """Function to map pw to CProject Objects"""
    P=CProject.CProject()
    dictData = REQUEST.form.items()
    strTemp = ""
    strError = "Error Retrieving Dictionary Value"
    ...etc...

Thanks for any help you can provide.