First off, sorry for posting a huge, stinkin' post like this, but instead of
posting ten times trying to explain what I do, I post this once and hope
somebody can point out what's wrong and I'll leave you all alone, at least
for a while. 

The example is from the Catalog outside Zope-tutorial available at
I'm using Zope 2.2.0. This might have been written for Zope 2.1.6. I dunno.

I understand the error message, just don't why it is raised. If I should
call some form of commit() or close(), where should this be done?

And, by the way, does Catalog support different kinds of searches, like
matching all the search-words, some, does the order count ? Can this options
be set, if any exists?

Anyway, thanks for your patience and bandwidth.

import sys
import ZODB
import Persistence
from Persistence import Persistent
from ZODB.FileStorage import FileStorage
from Products.ZCatalog.Catalog import Catalog

### create some classes to be persistent
class Nobody( Persistent ):
    def identify( self ):
        print "I am Nobody!"
class Person( Persistent ):
    def __init__( self, first, name, email, friend=Nobody() ):
        self.first = first  = name = email
        self.friend= friend
    def identify( self ):
        print "I am " + self.first + " " +
        print "and my Email is " +

### OK, the ZODB-API together with a Catalog-Class
class Application:
    def __init__( self, file='test.fs' ):
        self.file= file
        self.db  = ZODB.DB( FileStorage( file ) )  =
        if self.root.has_key( 'cat' ):
          = Catalog()
### This is, how I get it to work
### Add indexes to the Catalog-Class
### The names must match the fields of the Person-Class!
  'first','FieldIndex' )
  'name' ,'FieldIndex' )
  'email','FieldIndex' )
    def storePerson( self, person ):
        uid= id( person )
        print "stored as " + str( uid )
        self.root[uid]= person

### Let the Catalog know from this object person, uid )
    def searchPerson( self, **kw ):
        r= kw )
        root = self.root
        k= []
        for i in r:
            id= i.data_record_id_
            k.append( root[paths[id]] )
        return k

if __name__ == '__main__':
    a= Application()
    p1= Person( 'marian','kelc','[EMAIL PROTECTED]' )
    p2= Person( 'tanja', 'kreierhoff','[EMAIL PROTECTED]', p1 )
    p1.friend= p2
    a.storePerson( p1 )
    a.storePerson( p2 )

    a= Application()

    ### perform searches with keyword-arguments
    ids= a.searchPerson( name='kelc' )

    for i in ids:
        print "Friend is:"
        print str( id( i ) )
        print str( id( i.friend.friend ) )

stored as 24111488
stored as 16520248
Traceback (innermost last):
  File "D:\Program Files\Python\Pythonwin\pywin\framework\",
line 307, in RunScript, __main__.__dict__, start_stepping=0)
  File "D:\Program Files\Python\Pythonwin\pywin\debugger\", line
71, in run
    _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
  File "D:\Program Files\Python\Pythonwin\pywin\debugger\", line
533, in run
    _doexec(cmd, globals, locals)
  File "D:\Program Files\Python\Pythonwin\pywin\debugger\", line
868, in _doexec
    exec cmd in globals, locals
  File "D:\python\life\", line 84, in ?
    a= Application()
  File "D:\python\life\", line 28, in __init__
    self.db  = ZODB.DB( FileStorage( file ) )
  File "D:\PROGRA~1\WebSite\lib\python\ZODB\", line 262, in
  File "D:\PROGRA~1\WebSite\lib\python\ZODB\", line 115, in
    raise error, (
StorageSystemError: Could not lock the database file.  There must be
another process that has opened the file.

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to