see the zope book, advanced scripting chapter http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ScriptingZope.stx search for "Calling DTML from Scripts" Bart Hubbard wrote:
Hello again,
I have a python script that returns an object. I then call that script from DTML, and then call a method on that object, like this: <dtml-with expr="getArticleByCategory(findCat='cancer')"> <dtml-var view> </dtml-with>
I'd like to have my script call the method, and return the resulting HTML, instead, though. My script is the following:
import random
zcat = context.content.Catalog results = zcat(category=findCat) itemId = random.choice(results).id item = context.content.HealthFeatures[itemId] return item;
When I try to have the script call 'view()', I get a KeyError telling me I'm referencing a non-existent object or variable "headline" (which happens to be an attribute on that content object). So it looks like I'm having a namespace problem, which my DTML snippet at the top resolves.
So how do I accomplish in a single python script what I'm accomplishing above using DTML and python?
Much thanks, bart
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )