[Zope] Python script & recursive SQL?
Chris Cioffi
zope@stopthesanity.org
Sun, 16 Sep 2001 12:58:47 -0400
I'm writing a Yahoo! like directory (with a few customizations) as part of
learning Zope. Here's the setup:
link table uses a integer key to refer back to the category.
the category table has a pathto field in the form of ':1:2:3:' where 1, 2,
and 3 are the category keys to each category above the one we are currenty
looking at. ie Internet (1) : Servers (2) : Zope (3).
Now, using a simple python script I can parse out the individual numbers
from the pathto string. However, I've been having problems either returning
the list back to zope to run my 'category_name' ZSQL methods on each
element, or running 'category_name' directly from Python.
I can't find how the python script returns a list like a ZSQL method would
(I've looked in the Zope Book, searched zope.org, zdp.zope.org and did a
Google search on 'zope python script list return')
When I try to run the SQL method fom the Python script using
context.category_name(catid) or context.category_name(catnum=catid) I get
key errors.
Please help!
My last python script:
""" Takes the path in the form ':1:2:3:4:' and returns each item in turn """
import string
import types
cats = string.split(lpath, ':')
for i in cats:
if (i <> ''):
for catname in context.category_name(catid=int(i)):
if types.type(catname) == types.ListType:
print "it's a list"
else:
print "it's not a list"
return printed
This is Zope version 2.3.3, Python 1.5.2. (I'm planning on upgrading the
whole box and don't want to mess with just upgrading Python to run Zope 2.4
until then.)
Thanks
Chris