[Zope] help with zodb
Garrett G. Hodgson
garry@sage.att.com
Tue, 29 Feb 2000 16:35:02 -0500
okay, i'll try again, with some code this time.
i'm trying to use zodb to provide persistent store.
after various permutations swiped from the howto,
jim fulton's SPAM8 paper, and quick python, i've
still got the same basic problem, with no clue
what's wrong. so i've distilled it down to a
small example.
i've got a simple Person class, defined in Person.py:
import Persistence
class Person(Persistence.Persistent):
"""A Persistent Person"""
def __init__(self, name, age):
self.name = name
self.age = age
i can create a database and populate it by running a
small script (not shown here). it works fine when run
by hand.
i've also got a file in $ZOPE/Extensions called Keepers.py:
import ZODB, ZODB.FileStorage
db = ZODB.DB( ZODB.FileStorage.FileStorage( 'TestDB.fs' ) )
connection = db.open()
root = connection.root()
def GetPeople( self ):
"Return list of people in DB"
people = []
for key in root.keys():
people.append( root[ key ] )
return people
if __name__ == '__main__':
for person in GetPeople( None ):
print person.name, 'is', person.age, 'years old'
i can run this by hand, and it works fine.
so i create an External Method that points to GetPeople().
when i reference it in a DTML document, i get:
Could not lock the database file. There must be another process
that has opened the file.
and a lengthy traceback:
Traceback (innermost last):
File /usr/local/src/Zope-2.1.4-src/lib/python/ZPublisher/Publish.py,
line 214, in publish_module
File /usr/local/src/Zope-2.1.4-src/lib/python/ZPublisher/Publish.py,
line 179, in publish
File /usr/local/src/Zope-2.1.4-src/lib/python/Zope/__init__.py, line
202, in zpublisher_exception_hook
(Object: ElementWithAttributes)
File /usr/local/src/Zope-2.1.4-src/lib/python/ZPublisher/Publish.py,
line 165, in publish
File /usr/local/src/Zope-2.1.4-src/lib/python/ZPublisher/mapply.py,
line 160, in mapply
(Object: index_html)
File /usr/local/src/Zope-2.1.4-src/lib/python/ZPublisher/Publish.py,
line 102, in call_object
(Object: index_html)
File /usr/local/src/Zope-2.1.4-src/lib/python/OFS/DTMLDocument.py,
line 166, in __call__
(Object: index_html)
File
/usr/local/src/Zope-2.1.4-src/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
(Object: index_html)
File
/usr/local/src/Zope-2.1.4-src/lib/python/DocumentTemplate/DT_In.py, line
633, in renderwob
(Object: GetPeople())
File
/usr/local/src/Zope-2.1.4-src/lib/python/DocumentTemplate/DT_Util.py,
line 335, in eval
(Object: GetPeople())
(Info: GetPeople)
File <string>, line 0, in ?
File
/usr/local/src/Zope-2.1.4-src/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 239, in __call__
(Object: GetPeople)
File
/usr/local/src/Zope-2.1.4-src/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 195, in getFunction
(Object: GetPeople)
File /usr/local/src/Zope-2.1.4-src/lib/python/App/Extensions.py, line
205, in getObject
(Info: ('/usr/local/src/Zope-2.1.4-src/Extensions/Keepers.py',
'Keepers'))
File /usr/local/src/Zope-2.1.4-src/Extensions/Keepers.py, line 10, in
?
File /usr/local/src/Zope-2.1.4-src/lib/python/ZODB/FileStorage.py,
line 262, in __init__
File /usr/local/src/Zope-2.1.4-src/lib/python/ZODB/lock_file.py, line
101, in lock_file
StorageSystemError: (see above)
i've gotten this same message sometime when running by hand, typically
when
i called two routines in a row that each instantiated a ZODB.DB. so it
appears that this has something to do with the DB object not being
destroyed.
but i don't know how to make this work. i've sanned the archives, and
seen
no similar complaint, so i assume others don't have this problem.
any ideas why i do?
--
Garry Hodgson Every night
garry@sage.att.com a child is born
Software Innovation Services is a Holy Night.
AT&T Labs - Sophia Lyon Fahs