Changeset 8718
- Timestamp:
- 14 Jun 2012, 06:58:14 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/maintenance.py
r8417 r8718 6 6 import sys 7 7 from ZODB.scripts.analyze import report, analyze 8 from zope.component.hooks import setSite 9 from zope.component import getUtility 10 from zope.catalog.interfaces import ICatalog 11 from zope.intid.interfaces import IIntIds 12 from zope.location.interfaces import ILocation 8 13 9 14 def db_analyze(args=None): … … 26 31 27 32 report(analyze(path)) 33 34 def update_catalog(site, cat_name, objects=[], func=None): 35 """Update a catalog. 36 37 Put `objects` or objects delivered by `func()` into the catalog 38 registered under `cat_name` in `site`. 39 40 Objects to be catalogued must be 'located', i.e. they must have a 41 __name__ and __parent__ (because they are adapted to 42 IKeyReference). 43 44 You can pass in objects as some iterable or as a function that is 45 called to deliver the set of objects to be catalogued. 46 47 A function takes precedence over object lists. 48 """ 49 setSite(site) 50 cat = getUtility(ICatalog, name=cat_name) 51 intids = getUtility(IIntIds, context=cat) 52 if func is not None: 53 objects = func() 54 for ob in objects: 55 doc_id = intids.queryId(ob, None) 56 if doc_id is None: 57 doc_id = intids.register(ob) 58 cat.index_doc(doc_id, ob) 59 return cat
Note: See TracChangeset for help on using the changeset viewer.