Note that there are some explanatory texts on larger screens.

plurals
  1. POZODB / repoze.catalog - saving objects and catalog in same database?
    text
    copied!<p>I thought I understood this but I'm beginning to wonder !</p> <p>If you consider the <a href="http://docs.repoze.org/catalog/usage.html#indexing" rel="nofollow">repoze.catalog doco example</a> :</p> <pre><code>from repoze.catalog.catalog import FileStorageCatalogFactory from repoze.catalog.catalog import ConnectionManager from repoze.catalog.indexes.field import CatalogFieldIndex from repoze.catalog.indexes.text import CatalogTextIndex factory = FileStorageCatalogFactory('catalog.db', 'mycatalog') _initialized = False def initialize_catalog(): global _initialized if not _initialized: # create a catalog manager = ConnectionManager() catalog = factory(manager) # set up indexes catalog['flavors'] = CatalogFieldIndex('flavor') catalog['texts'] = CatalogTextIndex('text') # commit the indexes manager.commit() manager.close() _initialized = True class Content(object): def __init__(self, flavor, text): self.flavor = flavor self.text = text if __name__ == '__main__': initialize_catalog() manager = ConnectionManager() catalog = factory(manager) content = { 1:Content('peach', 'i am so very very peachy'), 2:Content('pistachio', 'i am nutty'), } for docid, doc in content.items(): catalog.index_doc(docid, doc) manager.commit() </code></pre> <p>This shows you how to generate the catalog entries for two instances of the Content class but what is the correct mechanism for actually saving the object ?</p> <p>I started out having a completely seperate ZODB database into which I stored the objects keyed on the docid used to catalog them under repoze.catalog but when it comes to transactions this is less than satisfactory because when adding an object I have to issue a commit on both the catalog and the ZODB database being used to store the objects.</p> <p>I had assumed that I would be able to access the ZODB catalog which is within the repoze.catalog structures and use that to store the actual objects but I'm having difficulties finding out how to do that .</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload