Hello all I'm newbie with Zope, ZODB and so on. First of all I have choiced Zope as application server and ZODB because I have to implement a bibliographical project that handles a lot of hierarchichal data, with need and will add in few months all the workflow related to send documents to a reviewer, publish, and have to connect with other bibliographic system through XML because of this is that I think could be made very easily with Zope/Plone, isn't it?
The first thing that I've tried to implement is to add functionality for search/add authors. For the business logic I have made an external-script that have the abstractions and the persistent-logic. After all the classes code I have defined two functions for invoking inside Zope. The entire idea is to put inside a Persistent class something that adds the functionality to search over the text of the objects properties. I'have found in this list an example that uses a Catalog, I think must be another way to search over a ZODB but have not found any example. For me a catalog is OK, perhaps later will want a TextIndex, but: ------- code ------ import sys sys.path.append('c:\\Archivos de programa\\Zope\\lib\\python\\') import ZODB import Persistence from Persistence import Persistent from ZODB.FileStorage import FileStorage from Products.ZCatalog.Catalog import Catalog class Autor(Persistent): id='' name='' observaciones='' 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'] else: self.cat = Catalog() ## I don't understand what is doing here self.cat.aq_parent= self.root self.root['cat']= self.cat self.cat.addIndex('id','FieldIndex' ) self.cat.addIndex('name' ,'FieldIndex' ) self.cat.addIndex('observaciones','FieldIndex' ) get_transaction().commit() def setAutor( self, autor ): uid= id( autor ) self.root[uid]= autor self.cat.catalogObject( autor, uid ) get_transaction().commit() 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 AddAutor(nombre,obs,documento): autores = Autores() autor = Autor(documento,nombre,obs) autores.setAutor(autor) def GetAutor(expresion,lista): autores = Autores() lista=autores.searchAutor(expresion) ------- end of code ------ I've tried this code with python. After waiting, python said: ------ python -------- >>> import dcAuthorDefClass Traceback (most recent call last): File "<stdin>", line 1, in ? File "dcAuthorDefClass.py", line 7, in ? from Products.ZCatalog.Catalog import Catalog File "C:\Archivos de programa\Zope\lib\python\Products\ZCatalog\__init__.py", line 16, in ? import ZCatalog, Catalog, CatalogAwareness, CatalogPathAwareness, ZClasses File "C:\Archivos de programa\Zope\lib\python\ZClasses\__init__.py", line 20, in ? import ZClass File "C:\Archivos de programa\Zope\lib\python\ZClasses\ZClass.py", line 16, in ? import Method, Basic, Property, AccessControl.Role, re File "C:\Archivos de programa\Zope\lib\python\ZClasses\Method.py", line 18, in ? import App.Dialogs, ZClasses, App.Factory, App.Product, App.ProductRegistry File "C:\Archivos de programa\Zope\lib\python\App\Factory.py", line 19, in ? import Products, Product File "C:\Archivos de programa\Zope\lib\python\App\Product.py", line 44, in ? from Factory import Factory ImportError: cannot import name Factory ------ end of python -------- My problem is that if I could not use a Catalog, what will I use? I could put a set of objects into a file and recovering by the id, but could not realize the way to search into the collection of objects and obtaining a filtered set or list. Another basic question. My first approach was to develop somenthing external to Zope to put my abstractions and drive the file storage, is this correct? Is there another way to map for example an abstraction with a folder, another abstraction with a file and so on, and for search using an standard catalog for example? My last question. Supposing that anybody could help me to make the above code work, I have a dtml-problem, how could I invoke an external method with parameters? I mean, I wish to call GetAutor with an expression like (name='a*') from dtml and after that iterate over the list that in some way, has returned from the external method to the dtml. Well, thanks a lot for your help and sorry by the extremely long of this mail Emiliano. _______________________________________________ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )