[Zope] Using Zope DB connection from a Python class
Ivan Raikov
ivan@faxnet.com
21 Jun 2000 09:35:10 -0400
Greetings,
For the past few days, I've been unsuccessfully trying to use a Zope
ODBC connection from within a Python class.
I have the following situation:
1. A Python class, Order, which has this method:
def create (self, cust_id, connection_id = None, itemcode = None,
quantity = 0):
while self is not None:
if hasattr(self, 'objectValues'):
for o in self.objectValues():
if hasattr(o, 'id'):
if o.id == connection_id:
self.connection = o
self.cust_id = cust_id
self.itemcode = itemcode
self.quantity = quantity
query = 'insert into orders (cust_id, itemcode, quantity) values (%s, \'%s\', %s)' % (self.cust_id, self.itemcode, self.quantity)
if self.connection != None:
self.connection._begin()
result = self.connection.query (query)
print result
self.connection._finish()
2. A Zope class, TestOrder, which subclasses Order. Its constructor
tries to invokes 'create', however upon executing the SQL query,
Zope either dies and is restarted, or just sits there, doing
nothing, until the HTTP connection times out. In either case, the
new record is not written in the database.
3. Zope 2.1.7
Z ODBC DA 3.0.3
Solid dev kit 2.3
RedHat Linux 6.1 on i386
Please help.
Thanks,
Ivan Raikov