[ZCM] [ZC] 90/ 3 Reject "Database Connection never drop if ZPT call external method with database connection"

Collector: Zope Bugs, Features, and Patches ... zope-coders@zope.org
Wed, 14 Aug 2002 11:12:44 -0400


Issue #90 Update (Reject) "Database Connection never drop if ZPT call external method with database connection"
 Status Rejected, Zope/bug critical
To followup, visit:
  http://collector.zope.org/Zope/90

==============================================================
= Reject - Entry #3 by matt on Aug 14, 2002 11:12 am

 Status: Accepted => Rejected

Closing as a stale issue
________________________________________
= Accept - Entry #2 by evan on Feb 15, 2002 2:07 pm

 Status: Pending => Accepted

 Supporters added: evan

This is probably caused by the object leak in earlier releases of ZPT.  Do you still have this problem with Zope 2.5's ZPTs?
________________________________________
= Request - Entry #1 by Anonymous User on Dec 14, 2001 3:58 pm

Database connection never drop if the database run-time error occurred in the external method called in Zope Page Template.

I tried to call the problem external method directly, of course, got the run-time error, but the connection was dropped in the database server.

And then I tried to use DTML method to call the problem external method, and they dropped the connection and I got the following error:
  Error Type: ProgrammingError
  Error Value: ('S0022', 207, "[Microsoft][ODBC SQL 
  Server Driver][SQL Server]Invalid column 
  name 'xx_facility_master_id'.", 4405)

Then I tried under Active Python 2.1 environment, connection can drop.


However, the error message reported by ZPT:

Error Type: TALESError
Error Value: mxODBC.ProgrammingError on ('S0022', 207, "[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'xx_facility_master_id'.", 4405) in ""


I guess the problem caused by ZPT error handling. If you need more information, please feel free to e-mail or call (604)713-4422. The detail information: 

PageTemplate 1.4.1
ZTUtils 1.1.3
TAL   1.4.1
MS SQL 7.0
mxODBC 

(a) ZPT:
    call external method id "ext_get_facility_list"

(b) external method:
    ext_get_facility_list

    id: ext_get_facility_list
    module: ext_rental
    function: get_facility_list

(c) under Extension, I have a file called ext_rental:

import mx.ODBC.Windows

class db:
    def __init__(self):    
        self.connection = mx.ODBC.Windows.DriverConnect( 'DSN=rental;UID=temprent;PWD=rental' )
        self.cursor = self.connection.cursor()
        
    def __del__(self):
        #if self.connection is not None:
        self.cursor.close()
        self.connection.close()


def get_facility_list(self, cp=113):
    """ Get a list of facility """

    o_db = db() 
    c = o_db.cursor

    sql = """
            select distinct facility_id as 'id', facility_name as 'name'
              from FACILITY 
             where xx_facility_master_id = ?
             order by facility_name
          """
    
    c.execute( sql, (cp,) )
    rs = c.fetchall()


    _result = []    
    for row in rs:
        _result.append( {'id':row[0], 'name':row[1]} )

    return _result


Thank you.


-----------
James Poon
Vancouver School Board
(604) 713-4422





==============================================================