You are not logged in Log in Join
You are here: Home » Members » aaltepet's Home » Rebuilding Silva's ZCatalog » howto_view

Log in
Name

Password

 

Rebuilding Silva's ZCatalog

 

Created by aaltepet . Last modified 2005-05-05 19:38:49.

Our production ZCatalog used by Silva became corrupt and had to be rebuilt. Here's how we did it.

For whatever reason, a piece of Silva's catalog (id: service_catalog) become corrupted. This caused the SilvaNews product, which uses the catalog heavily to retrieve news items and such, to 'miss' news items. The error, a POSKeyError, was being quietly ignored. I tried the methods described in http://www.zopelabs.com/cookbook/1054240694 to locate the bad object. This failed, however, because the bad object was inside the zcatalog. So, the remedy was to reindex the catalog. Silva has a controlled used of the catalog, placing only public and unapproved versions of versioned content (silva documents, silva news items) in the catalog. So, here are the steps I took:

  • cleared the catalog (advanced tab of the catalog)
  • attempting to reindex all silva objects at once, if your silva tree is large, will take a long time and may fail. So, I indexed three sets of non-versioned content (SilvaNews? content/containers, Silva containers, silva content). Nothing else needs to be done to this set of objects.
  • I have no idea, and I doubt anyone else does, how to use the 'expr' component of the 'find objects' tab. Aparrently you can specify a dtml expression, but that never worked and in fact quietly failed. If I could have figured this out, the rest of this process would have been much easier. Ideally, you'd specify a dtml expression and use it to only index those versions that have a version_status of either public or unapproved.

    So, I indexed all versioned objects in three four (SilvaNews? agenda and article versions, Silva versioned content like links and ghosts, Silva document versions modified before the first of the year, and silva document versions modified after the first of the year).

  • Once everything silva-content/container related was indexed, I ran a python script multiple times to remove the different versioned content objects that had a version_status of closed or last_closed. Here is the python script:

    def zcatalog_fix(context):
      text = ''
      #look in zcatalog
      zc = context.service_catalog
      res = zc(meta_type={'query':'Silva Document Version'},
               version_status={'query':['closed','last_closed']})
      for r in res:
        obj = r.getObject()
        path = '/'.join(obj.getPhysicalPath())
        status = obj.version_status()
        if obj.version_status() not in ('unapproved','public','approved'):
          zc.uncatalog_object(path)
          text += 'uncatalog: ' + path + '\n'
        text += status + '\n' 
      text += str(len(res)) + 'a'
      return text
    

    This function can be run inside any pythonscript. Return the value returned from this function to see what objects were uncataloged.