[Zope] ZClass Methods and Namespace issues
Ted Pollari
tcp@uchicago.edu
Thu, 14 Nov 2002 19:20:27 -0600
I'm having trouble with what must be a namespace issue involving python,
DTML and ZClasses.
Using Zope 2.6:
I'm working on a ZClass designed to allow for the easy creation of a
web-based survey system.
My "Question" ZClass is defined in a product in the Zope products directory.
Within each instance of the Question ZClass (which are folderish) there is a
dtml document called FormPiece (created by the Question Class constructor)
that includes a small snippet of html and dtml.
The html is form inputs which get their name value from a dtml-var tag that
calls a python-script method. That python-script method is defined in the
Question Class itself.
If I view the FormPiece item itself from the management interface, it all
works fine and the python-script is found and works as intended.
Problems arise when I am calling the FormPiece in a different way...
When I call another python-script, named "ReturnFormItem" that is a method
of the Question Class on one of the Question Class objects an error is
generated...
Here are the contents of the ReturnFormItem:
###############
print "<!-- My Sql id is: " + `context.ReturnSQLId()` + "-->"
print context.FormPiece()
Return printed
###############
Now, when this script method is called on one of the Question Class
instances, this returns a key error because FormPiece contains a dtml-var
tag call to the method "ReturnSQLId" which is a method of the Question
Class. Interestingly, though, the call to the same ReturnSQLId method in
the ReturnFormItem script works fine.
So it seems to me that by calling context.FormPiece() and then trying to
call the ReturnSQLId inside the FormPiece document is being called without
the "normal" namespace... Correct? If that is the case, how do I get the
call to context.FormPiece() to use the same namespace as if I were calling
FormPiece directly, such as from a URL?
Or am I completely confused about all this?
Thanks is advance,
-Ted