[Zope] Accessing Zope DA connection from external method

Chui Tey Chui.Tey@env.qld.gov.au
Tue, 28 Sep 1999 14:20:15 +1000


OK this worked:

def external_query(self):
    sql = """
       SELECT CreatedBy, AssignTo, DateCreated 
       FROM tblJOB WHERE CreatedBy LIKE '%phil%'
    """
    return self.connODBCJob().query(sql)
        
but this didn't

# in Extensions/testconn.py
def external_query(self):
    return self.connODBCJob.query('SELECT * FROM tblJOB')

and this hangs Zope (I think)
# in Extensions/testconn.py
def external_query(self):
    c = self.connODBCJob()
    return c.query('SELECT * FROM tblJOB')

Only caveat is that the <dtml-in> tag doesn't seem to work with this
external method.


Hannu Krosing wrote:
> 
> Chui Tey wrote:
> >
(snip)
> > Can anyone point out how do I reference a Zope DA Connection from an
> > external method. This way I can make use of an existing open connection
> > instead.
> 
> >From a short look at the source it seems that you can just use
> 
> YourZopeConnection.query('select * from data')
> 
> I quess the result will be the same as from using ZSQL Method, but it
> may be something simpler.
> 
> If you find something out, please let us know too ;)
> 
> -------------
> Hannu