Hello all

Finally could find where and how to add indexes in the actual way (think
so). Now I have another problem that have no idea how to fix it. Could
add objects into a ZODB separate database, could add the catalog and the
index, but when the database has one element, with every operation
(inclusive opening it) this message appears from Zope:

'App.PersistentExtra' module has no attribute 'Autor'

>From Python

  File C:\Archivos de programa\Zope\lib\python\ZODB\Connection.py, line
534, in etstate
  File C:\Archivos de programa\Zope\lib\python\ZODB\Connection.py, line
178, in_persistent_load
    (Info: ('\x00\x00\x00\x00\x00\x00\x00\x0e', ('App.PersistentExtra',
  File C:\Archivos de programa\Zope\lib\python\ZODB\Connection.py, line
138, in __getitem__
    (Info: ('\x00\x00\x00\x00\x00\x00\x00\x0e',

Juana Silviaq\x08U\robservacionesq\tU\x0bpruebaq\nu.'))
  File C:\Archivos de programa\Zope\lib\python\ZODB\DB.py, line 122, in
AttributeError: 'App.PersistentExtra' module has no attribute 'Autor'

Simply, I have no idea what is happening, have searched over
App.PersistentExtra but...what is???? Somebody knows where could I find
an example (that works and is updated) for doing this kind of tasks?

My code is:
import sys
import ZODB
import Persistence
from Persistence import Persistent
from ZODB.FileStorage import FileStorage
from Products.ZCatalog.Catalog import Catalog
from Products.PluginIndexes.FieldIndex.FieldIndex import FieldIndex

class Autor(Persistent):

     def __init__(self,id,nombre,comments):
         self.name = nombre
         self.id = id
         self.observaciones = comments

     def setName(self,nombre):
         self.name = nombre

     def setId(self,id):
         self.id = id

     def setObs(self,comments):
         self.observaciones = comments

     def getName(self):
         return self.name

     def getId(self):
         return self.id

class Autores:
     def __init__( self, file='dcAuthor.fs' ):
        self.file= file
        self.db  = ZODB.DB( FileStorage( file ) )
        self.co  = self.db.open()
        self.root= self.co.root()
        if self.root.has_key( 'cat' ):
             self.cat= self.root['cat']
             self.cat        = Catalog()
      ### This is, how I get it to work
             self.cat.aq_parent= self.root
             self.root['cat']= self.cat

             ### Add indexes to the Catalog-Class
             ### The names must match the fields of the Person-Class!

              indice = FieldIndex('id')
             self.cat.addIndex('id',indice )
             otroIndice = FieldIndex('name')
             self.cat.addIndex('name' ,otroIndice )
###            self.cat.addIndex('observaciones','FieldIndex' )

     def setAutor( self, autor ):
         uid= id( autor )
         self.root[uid]= autor
         print "Guardada como:"+str(uid)

        ### Let the Catalog know from this object
        self.cat.catalogObject( autor, uid )

     def searchAutor( self, **kw ):
        r= self.cat.searchResults( kw )
        paths= self.cat.paths
        root = self.root
        k= []
        for i in r:
                 id= i.data_record_id_
                 k.append( root[paths[id]] )
        return k

     def close ( self ):

def AddAutor(nombre,documento,obs):
   autor = Autor(documento,nombre,obs)
   autores = Autores()

def GetAutor(expresion):
   autores = Autores()
   for au in listaAutores:
   return listaretorno


I've seen that if I no close() the database, only obtain Error 500 from
the server. GetAutor and AddAutor are called from DTML.

Well, thanks a lot again.

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to