Whoops! Good point. I had edited my question many times w/o changing the title. My real situation is a little more complex than the question I'd posed. What I'm really doing is trying to do in ZPT what I was doing in a DTML doc. I also wanted to clean up my design by moving the logic to my script. My script finds an object fine, but I couldn't get it to execute a method properly that the object contained. Thanks to Peter Sabaini's hint, I have it working now. I now have the script explicitly setting the context before attempting to execute the method. The updated test script now works great, and is (no error handling in there, yet): import random # Get content catalog and search for an object using the args # and the current date/time zcat = context.content.Catalog results = zcat(category=findCat, meta_type=findType, publishDateRange=DateTime()) # Pick one content object at random item = random.choice(results).getObject() # Prepare to call the view method on the content object dtml_method = item.view REQUEST = context.REQUEST # Call the method in the context of that item and return the results retVal = dtml_method(client=item, REQUEST=REQUEST) return retVal Next I plan to allow various 'views' to be requested from the script based on an argument, as well. Then I'll have a good script to use in my ZPTs to request the various types of content I have indexed. Thanks for the help, bart
-----Original Message----- From: Chris Withers [mailto:chrisw@nipltd.com] Sent: Wednesday, September 03, 2003 8:15 AM To: Bart Hubbard Cc: zope@zope.org Subject: Re: [Zope] Calling Python script from ZPT [...]
Why the ZPT title?
If you were using ZPT you probably wouldn't have the problem ;-) [...]