[Zope] Problem with Binding Classes to Results of SQL Methods

Stephen Pitts smpitts@ender.midsouth.rr.com
Fri, 23 Jul 1999 10:58:57 -0500


Hi!
I was looking at the Z SQL Method's User's Guide at
http://www.zope.org/Documentation/Guides/ZSQL/ZSQL-HTML/ZSQL.html,
and I'm interested in the "defining Result classes" section.
I've got some data in MySQL format right now, and I want to 
wrap a Python class around it "the Zope way" so that I can
access/update properties of the object without embedding
SQL in my Python code (I did that some in PHP3, and now my
code is somewhat unreadable :-().

So, I defined a class "School.py" in 
/usr/local/Zope/python/lib/Shared/smpitts and created 
an empty __init__.py file in that directory. I then added 
the following line to /usr/local/Zope/Extension/smpitts_utils.py:
"from Shared.smpitts.School import School". Here's my class
definition in School.py:

"""Represent a School in the MSC Database"""
class School:
	""Represent a School"""
	def test(self):
		return "Yippee..I'm a School Object!"
								
I also created an Z MySQL Database Connection in 
the Test folder of my Zope server. (The docs 
are really bad on this: I had to look through
several source files before I found a very large
doc string with connection info. Why that is 
not shown when I enter an invalid connect string
is my guess). It connected OK to my MySQL
server (version 3.22.25). I created a simple SQL
method with the parameter SchoolId and this SQL:
SELECT * FROM Schools WHERE 
<!--#sqltest SchoolId column=SchoolId type="string"-->
and called it School. In the Advanced tab, I
told Zope to use Class Name: School and Class
File: smpitts_utils for the results. It appeared
to work, I tried entering invalid module names
and it generated error messages, but when I 
entered the actual modules, it found the class
OK.

Testing the method worked great, and looked up
School data perfectly. However (from the Docs), 
I thought I should be able to do something
like this to run the test method:
http://orwell:9673/Test/School/SchoolId/GRAH/test
I got a "Resource Not Found" message. 
Just doing this:
http://orwell:9673/Test/School/SchoolId/GRAH
gives me the index_html object for /Test/,
demonstrating the Acquisition works OK.

What am I doing wrong? Is that piece of 
Documentation dated? Should I be using
Z-Classes to accomplish this instead?
I've got a some data in MySQL format
(about 4,000 rows), and I want to reap
the benefit of encapsulating them in
Objects without having to manually,
(or programmatically), add them all
to Zope. 

FWIW, I'm running Zope 2.0a4 on Linux/x86 
2.2.10, Python 1.5.2 (the version that
is packaged in Debian potato).

-- 
Stephen Pitts
smpitts@midsouth.rr.com
webmaster - http://www.mschess.org