[Zope] Globals disappearing in extmethod?
Joseph A Knapka
jknapka@earthlink.net
Mon, 04 Feb 2002 01:07:42 +0000
Hello, friends.
It may be that I am misunderstanding something fundamental.
I have code that does essentially the following:
(1) Defines an external method for processing form data:
# In module MyModule:
def myExtMethod(req):
global Request
Request = req
action = getFormData("action")
#...process request...
# And a utility function to help out - this is not an
# external method, but is used by myExtMethod.
def getFormData(key):
return Request.get(key)
(2) Defines a DTML document that just passes its input
along to myExtMethod():
...
<dtml-var expr="myExtMethod(REQUEST)">
...
The point of this is that myExtMethod() is a wrapper
around some old CGI code; I want the state of MyModule
to be preserved between invocations of myExtMethod(),
for performance reasons. I've been working with Zope
for only a very short time (days), so I don't know if
this is the "right" way to do this; I'd appreciate any
advice on this matter.
Now the problem. This code works most of the time.
However, apparently at random, when executing
a request, I will get an exception from getFormData():
"global name Request does not exist." This is very
strange, because /every/ invocation of getFormData()
is called from myExtMethod(), so there's simply no way
the Request global can be unset, as far as I can see.
Can anyone explain what is happening here? A pointer
to relevant documentation would be sufficient; I've
got "The Zope Book" and "The Book of Zope", neither
of which have been much help about this particular
issue (though quite helpful in many other ways).
Many thanks,
-- Joe
"I should like to close this book by sticking out any part of my neck
which is not yet exposed, and making a few predictions about how the
problem of quantum gravity will in the end be solved."
--- Physicist Lee Smolin, "Three Roads to Quantum Gravity"