[Zope] dtml-in over python script
Kevin Carlson
khcarlso@bellsouth.net
Sun, 7 Jul 2002 16:01:17 -0400
Charlie,
You want to use a dictionary. Should work just fine without having to
resort to external file system code. Let me know if you need an example of
this.
Kevin
-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
Charlie Reiman
Sent: Friday, July 05, 2002 6:02 PM
To: zope@zope.org
Subject: [Zope] dtml-in over python script
I have a SQL query that I need to wrap in a Python script. Fine and dandy.
I'd like the results of the python call to be accessable with dtml-in but
with custom field/attribute names.
I other words, I want to be able to do this:
--- dtml ---
<dtml-in MyPythonScript>
<dtml-var favorite_food>
<dtml-var favorite_color>
</dtml-in>
And this:
--- MyPythonScript ---
rawresults = context.query_favorites()
results = []
for rawitem in rawresults:
food, color = results[0].bigfield.split(',')
results.append(???)
return results
----
What would I place in the ??? field? I've tried:
A dictionary ("{'favorite_food':food, 'favorite_color':color}").
An object (placing a small class in the script. Fails to create the object.)
I've also tried adding my attributes to the existing result objects but that
also fails.
Suggestions? This seems like it should be pretty easy.
_______________________________________________
Zope maillist - Zope@zope.org
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 )