[Zope] SQL methods in __init__

Garion jsuther1@twcny.rr.com
Tue, 18 Apr 2000 22:21:02 -0400


Garion wrote:
> 
> I would like to access some SQL methods (similarly defined as in the
> SQLSession product), but I can't seem to do it.. I have tried everything
> i can think of... Setting a flag for later addition is not really an
> option that I would want to do... I would think that this is a common
> enough problem that it can be solved easily.. Does anyone out there have
> any ideas?
> 
> --John

I'm gonna try to explain what I'm trying do, since I'm sure the above
isn't too clear.. Frustration has set in...

I have a folder off my root folder that I'll call MyWebSite... In
MyWebSite, I have a MySQL Connection defined... When I add an instance
my new product, I want it to save various bits into tables off the MySQL
Connection, and use the LAST_INSERT_ID for the ID of the object.. 

My problem seems to be when I try to do this in the __init__ of my
product, I haven't aquired the environment, and tells me that it can't
find MySQL Connection..

I've tried various tricks like moving my SQL calls to the manage_add
function, after the call to my __init__, after the call to setObject
(which defeats the purpose of me using the LAST_INSERT_ID asthe ID of
the object), and even after the call to manage_main..

Is there some kind of Zope magic I can use to get around this?? Someone
a while back suggested having a flag saying if its in the database or
not, and checking the flag constantly. THis is not a solution, as I need
to have the info in the database as its entered (an external program
interfacing to it), and can't wait for an indeterminant amount of time
till someone clicks on my product...

Any ideas out there?

--John