[Zope] Question about MySQL queries in Python Scripts

Kevin Teague kevin@bud.ca
Sun, 25 Feb 2001 03:25:36 -0800


> I've written a few python scripts that use some sql queries to a mysql
> database. I have a script that can access the database and get information ok
> but i have a sript that tries to insert data to the database, but when i try
> to run it, i get a zope error that mentions Unauthorized: query.
> 
> Does anyone know why this is and how to get round it?

Hmm, some more information about your script or the traceback in your error
message would be helpful. If I wanted to create SQL queries in a python
script, I would create a MySQL DB connection in Zope, then a simple Z SQL
Method that took a single arguement as a string, like this:

Params: query:string
Method: <dtml-var query>

Then I'd only allow Manager access to this Z SQL Method and then give the
python script a proxy role so that it could access the Z SQL Method. Then
call that Z SQL Method from the Python Script perhaps like this:

container['zsqlmethodid'](query='SELECT * FROM your_table')

Kevin Teague
http://www.bud.ca