Re: [ZODB-Dev] tcp_begin in tests

2005-07-07 Thread Antonio Beamud Montero
El mié, 06-07-2005 a las 19:57 +0200, Antonio Beamud Montero escribió:
 Hi all:
 In my app, I'm using ZODB to store data, the problem is that I have
 implemented several unittest, for every unit test I create the ZODB
 database and when the test finished I destroy the database (including
 files). When I run 2 test, the first is executed ok, but the second
test
 give me the next Exception:
 
 Traceback (most recent call last):
   File ./test_collector.py, line 240, in runTest
 self.collect = Collector(conf)
   File /usr/lib/python2.3/site-packages/mylib/collector.py, line 78,
 in __init__
 get_transaction().commit()
   File /opt/zope/lib/python/ZODB/Transaction.py, line 232, in commit
 self._commit_begin(jars, subjars, subtransaction)
   File /opt/zope/lib/python/ZODB/Transaction.py, line 340, in
 _commit_begin
  jar.tpc_begin(self)
   File /opt/zope/lib/python/ZODB/Connection.py, line 692, in
tpc_begin
 self._storage.tpc_begin(transaction)
 AttributeError: 'NoneType' object has no attribute 'tpc_begin'
 
 To shutdown the class containing the ZODB connection:
 
   def shutdown(self):
 self.db.close()
 self.storage.close()
 return
 
 But, if I execute only the second test, all works ok...
 I've try to debug the problem, but the ZODB code is very deep and
 complex...
 

Sorry, I not give you all the info:

To open the database:
testdata = '/tmp/zodb.fs'
class Collector:
def __init__(self, config=None):
try:
self.storage = FileStorage.FileStorage(testdata, create=1)
self.db = DB(self.storage)
self.db.setPoolSize(20)
zodbcon = self.db.open()
root = zodbcon.root()
except Exception,e:
sys.exit(0)
if not root.has_key('pendings'):
root['pendings'] = Status('pendings')
get_transaction().commit()

def shutdown(self):
 self.db.close()
 self.storage.close()
 return

The problem arises when the commit() is executed...

I have tested ZODB but the problem doesn't raises...

Greetings.


___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


RE: [ZODB-Dev] tcp_begin in tests

2005-07-07 Thread Antonio Beamud Montero
El mié, 06-07-2005 a las 14:19 -0400, Tim Peters escribió:
 [Antonio Beamud Montero]
  In my app, I'm using ZODB to store data, the problem is that I
  have implemented several unittest, for every unit test I create the ZODB
  database and when the test finished I destroy the database (including
  files). When I run 2 test, the first is executed ok, but the second test
  give me the next Exception:
 

With the files attached I can simulate the same problem, i.e. when close
the DB connection and after call commit()...
But I can't see this pattern (i.e. open-close-commit) in my code... only
when two tests are executed (i.e. create and destroy the database), and
only occurs between two tests, the rest of the tests works well...
This is very strange...

I'll investigate and send you my conclusions

Greetings
#!/usr/bin/env python

import unittest
from coll import Collector
CollectorTestSuite = unittest.TestSuite()

class CollectorTest(unittest.TestCase):
def setUp(self):
self.collect = None
def tearDown(self):
	if self.collect:
	self.collect.drop()

class Test1(CollectorTest):
def runTest(self):
self.collect = Collector()

CollectorTestSuite.addTest(Test1(runTest))

allsuites = (CollectorTestSuite,)
if __name__ == '__main__':
   csuite = unittest.TestSuite(allsuites)
   runner = unittest.TextTestRunner()
   runner.run(csuite)
from ZODB import DB, POSException, FileStorage
from Persistence import Persistent
from BTrees.OOBTree import OOBTree

class Values(Persistent):
def __init__(self):
  self._dicc = OOBTree()
def set(self, v, s):
self._dicc[v] = s  


class Collector:
   def __init__(self):
   self.storage = FileStorage.FileStorage('/tmp/zodb.fs', create=1)
   self.db = DB(self.storage)
   con = self.db.open()
   root = con.root()
   if not root.has_key('pendings'):
   root['pendings'] = Values()
   #root.close()
   con.close()
   #self.db.close()
   get_transaction().commit()

   def drop(self):
   self.db.close()
   self.storage.close()

if __name__ == '__main__':
   c = Collector()
   

___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


RE: [ZODB-Dev] tcp_begin in tests [SOLVED]

2005-07-07 Thread Tim Peters
[Antonio Beamud Montero]
 Solved... well, as you can see in the traceback, the zope-ZODB library
 was in the path, and I want using the ZODB alone installed in the python
 lib path... I've removed the /opt/zope/lib/python from my app pythonpath,
 and now all works fine...

Great!  I'm especially glad you were able to solve it, because it was
looking pretty certain that nobody else here was going to wink.

BTW, doing a DB.close() automatically calls close() on the storage too, so
you could simplify your code a little bit.

___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


RE: [ZODB-Dev] tcp_begin in tests

2005-07-06 Thread Tim Peters
[Antonio Beamud Montero]
 In my app, I'm using ZODB to store data, the problem is that I
 have implemented several unittest, for every unit test I create the ZODB
 database and when the test finished I destroy the database (including
 files). When I run 2 test, the first is executed ok, but the second test
 give me the next Exception:

 Traceback (most recent call last):
   File ./test_collector.py, line 240, in runTest
 self.collect = Collector(conf)
   File /usr/lib/python2.3/site-packages/mylib/collector.py, line 78,
 in __init__
 get_transaction().commit()
   File /opt/zope/lib/python/ZODB/Transaction.py, line 232, in commit
 self._commit_begin(jars, subjars, subtransaction)
   File /opt/zope/lib/python/ZODB/Transaction.py, line 340, in
 _commit_begin
  jar.tpc_begin(self)
   File /opt/zope/lib/python/ZODB/Connection.py, line 692, in tpc_begin
 self._storage.tpc_begin(transaction)
 AttributeError: 'NoneType' object has no attribute 'tpc_begin'

 To shutdown the class containing the ZODB connection:

   def shutdown(self):
 self.db.close()
 self.storage.close()
 return

This is the only code of yours you've shown us, and, sorry, but it's not
much to go on.  We haven't even seen how you open a database.

 But, if I execute only the second test, all works ok... I've try to debug
 the problem, but the ZODB code is very deep and complex...

 Can anybody help me?

Probably not, without more info.  ZODB comes with a large test suite of its
own -- maybe you could study how it opens and closes databases in its own
tests.  Short of that, try to create a minimal, self-contained, failing
test, and post the entire code for that; for what should be obvious reasons,
it's hard debug code we can't see.

 ZODB3-3.2

That's very old now.  ZODB 3.2.8 is the current stable release in the 3.2
line.

 python-2.3.3
 Linux Suse 9.1

___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev