[Zope] context in Python Script

2000-11-28 Thread Chris Gray

I still can't get external Python Scripts to work as described in the Zope
Book.  I am using the version of Python Scripts from the public
CVS.  Internal Scripts work fine, but I can't seem to use the
"context" object in an external script.

def tryContext():
"""tryContext function"""
return context.objectIds()

gives a NameError on context.

--

def tryContext(context):
"""tryContext function"""
return context.objectIds()

with the "Try It" tab, no form for passing parameters comes up and the
complaint is that the context parameter was omitted from the request.

---

dtml-var tryContext

to the first example above gives the same NameError on context and to the
second example gives "a not enough arguments" TypeError

---

It only seems to work when explicitly passing an argument like

dtml-var "tryContext(this())"

but I thought that context was supposed to be bound to an object by
default as it is with an Internal Script.

Cheers,
Chris


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] context in Python Script

2000-11-28 Thread Dieter Maurer

Chris Gray writes:
   "context" in external Python Script 
I do not yet know, what an external Python script is.

In the old "external methods", you had to use "self"
as first parameter. Then (in most cases), you
could use "self" inside the function body, as you
would now use "context".

Maybe, you give it a try.


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )