[Zope] Adding an External Method
John Poltorak
jp at warpix.org
Mon Mar 15 05:50:58 EST 2004
I have been following a worked example which shows how to add an External
Method - something I have never done previously and it isn't working out
as described in the article. Could someone suggest what is wrong?
Here is the actual article:-
http://www.zopemag.com/Issue006/Section_Articles/article_IntroToArchteypes.html
I followed it religiously as far as this:-
Now, give it a try:
* Restart Zope
* Make sure the product got imported just fine
* Create a Plone Site
* Create an External Method:
id: install_article
module: MyArticle.Install
function: install
* Run the External Method
* Check that it worked by looking inside portal_types to see if it
contains a type named "Article".
Instead of it working when I run it, it fails with:-
Traceback (innermost last):
* Module ZPublisher.Publish, line 150, in publish_module
* Module Products.PlacelessTranslationService.PatchStringIO, line 45, in new_publish
* Module ZPublisher.Publish, line 114, in publish
* Module Zope.App.startup, line 202, in zpublisher_exception_hook
* Module ZPublisher.Publish, line 98, in publish
* Module ZPublisher.mapply, line 88, in mapply
* Module ZPublisher.Publish, line 39, in call_object
* Module Products.ExternalMethod.ExternalMethod, line 59, in manage_addExternalMethod
* Module Products.ExternalMethod.ExternalMethod, line 110, in __init__
* Module Products.ExternalMethod.ExternalMethod, line 133, in manage_edit
* Module Products.ExternalMethod.ExternalMethod, line 140, in getFunction
* Module App.Extensions, line 145, in getObject
__traceback_info__: ('C:/USR/local/zope/lib/python/Products/MyArticle/Extensions/Install.py',
'MyArticle.Install')
* Module C:/USR/local/zope/lib/python/Products/MyArticle/Extensions/Install.py,
line 1, in ?
ImportError: cannot import name GLOBALS (Also, an error occurred while
attempting to render the standard error message.)
This is what Install.py contains:-
from Products.MyArticle.config import PROJECTNAME, GLOBALS
from Products.Archetypes.public import listTypes
from Products.Archetypes.Extensions.utils import installTypes
from StringIO import StringIO
def install(self):
out = StringIO()
installTypes(self, out,
listTypes(PROJECTNAME),
PROJECTNAME)
print >> out, "Successfully installed %s." % PROJECTNAME
return out.getvalue()
I have no idea what GLOBALS pertains to and whether it is some sort of
keyword in Python and it may well be due to an incorrect install of
Python, but as I see it, I have followed the instructions in the article
but it hasn't worked. Can anyone suggest what the cause might be and what
I need to change to fix it?
--
John
More information about the Zope
mailing list