Changeset 1890 for WAeUP_SRP/trunk
- Timestamp:
- 13 Jun 2007, 10:40:51 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTool.py
r1875 r1890 28 28 from OFS.SimpleItem import SimpleItem 29 29 30 from Products.CMFCore.utils import getToolByName 30 31 from Products.CPSSchemas.DataStructure import DataStructure 31 32 from Products.CPSSchemas.DataModel import DataModel … … 35 36 from Products.ZCatalog.ZCatalog import ZCatalog 36 37 from Products.CMFCore.permissions import ModifyPortalContent 38 from Products.CMFCore.permissions import ManagePortal 37 39 from Products.CMFCore.utils import UniqueObject 38 40 from Products.CMFCore.URLTool import URLTool … … 127 129 return pw 128 130 ###) 131 132 security.declareProtected(ManagePortal, 'removeDeletedDocIds') ###( 133 def removeDeletedDocIds(self, max=1000): 134 """ 135 remove deleted docids from repository commit after max 136 """ 137 logger = logging.getLogger('WAeUPTool.removeDeletedDocIds') 138 repository = getToolByName(self, 'portal_repository') 139 pxtool = getToolByName(self, 'portal_proxies') 140 pxtool_infos = pxtool.getRevisionsUsed() 141 142 nb_revs = 0 143 docids_d = {} # all docids 144 unused_docids_d = {} # all docids that are unused 145 ids_unused_revs_docids = [] # ids for revs of unused docids 146 ids_unused_revs = [] # ids for unused revs 147 total = 0 148 for id in repository.objectIds(): 149 docid, rev = repository._splitId(id) 150 if docid is None: 151 logger.info("invalid doc_id %s" % docid) 152 continue 153 nb_revs += 1 154 docids_d[docid] = None 155 if not pxtool_infos.has_key(docid): 156 unused_docids_d[docid] = None 157 ids_unused_revs_docids.append(id) 158 ids_unused_revs.append(id) 159 elif not pxtool_infos[docid].has_key(rev): 160 ids_unused_revs.append(id) 161 if len(ids_unused_revs) >= max: 162 repository.manage_delObjects(ids_unused_revs) 163 #import pdb;pdb.set_trace() 164 transaction.commit() 165 total += max 166 logger.info('removed %d total %d unused docids ' % (max,total)) 167 anz = len(ids_unused_revs) 168 if anz > 0: 169 repository.manage_delObjects(ids_unused_revs) 170 transaction.commit() 171 total += anz 172 logger.info('finished removing %d unused docids ' % (total)) 173 174 175 ###) 129 176 130 177 security.declareProtected(ModifyPortalContent,'getCredential') ###(
Note: See TracChangeset for help on using the changeset viewer.