Reputation: 1743
I am having a problem getting a Python script in Plone to find an External Method. Given three different objects:
CloneList
(Id and Function Name)A DTML Document that references it successfully using this
<dtml-var "CloneList(PAGE,ORG,STATUS,CGAP_DATA_HOME,BASE)">
A Python script that references the external method via this...
return CloneList(PAGE,ORG,STATUS,CGAP_DATA_HOME,BASE)
The DTML document works fine but the Python script, for some reason throws:
Error Value: global name 'CloneList' is not defined
Why can the DTML template see CloneList just fine but the Python script can't?
Upvotes: 2
Views: 225
Reputation: 1121962
The DTML namespace includes the current context, the Python Script namespace does not. The Python code has to use explicit methods to reference other objects outside of the script.
You can use the context
object to reference other objects in the ZODB, like the External Method:
return context.CloneList(PAGE, ORG, STATUS, CGAP_DATA_HOME, BASE)
You can also look up the name on container
; where context
uses the acquisition chain to look for names, container
only looks at the folder the script lives in, plus all parent folders.
Upvotes: 5