e9d03958856dd2b23e38511ad5bc4124d7331482
1 from argparse
import ArgumentParser
3 from Acquisition
import aq_base
4 from zope
.site
.hooks
import setSite
5 from Products
.CMFCore
.CMFCatalogAware
import CMFCatalogAware
8 # portal = app.realismc
10 # ctool = portal.portal_catalog
12 # errorLog = open('/home/zope/checkcontents-errors.log', 'w')
15 def checkContents(ob
) :
18 print ob
.absolute_url()
20 print >> errorLog
, '%s/%s' % (ob
.aq_parent
.absolute_url(), ob
.aq_base
.id)
21 print >> errorLog
, getattr(ob
, 'portal_type', getattr(ob
, 'meta_type', ''))
25 if isinstance(aq_base(ob
), CMFCatalogAware
) :
26 assert ob
._getCatalogTool
()
30 if count
% 1000 == 0 :
32 print count
, 'commit.'
34 print >> errorLog
, '%s/%s' % (ob
.aq_parent
.absolute_url(), ob
.aq_base
.id)
37 if hasattr(aq_base(ob
), 'objectItems') :
38 obs
= ob
.objectItems()
43 parser
= ArgumentParser(description
="Deflate blobs backup set.")
44 parser
.add_argument('portal_path')
45 parser
.add_argument('--error-log', help='Error log file. Default: ~/catalog-rebuild-error.log',
46 default
='~/catalog-rebuild-error.log', required
=False, dest
='errorLogPath')
48 args
= parser
.parse_args()
49 portal
= app
.unrestrictedTraverse(args
.portal_path
)
51 ctool
= portal
.portal_catalog
52 errorLogPath
= os
.path
.expanduser(args
.errorLogPath
)
53 errorLog
= open(errorLogPath
, 'w')