Commit d7dd1089 authored by Michel Pelletier's avatar Michel Pelletier

Improved handling of subtransactions. Should keep memory from

ballooning beyong the capacity of the machine.  Note: while mass
indexing, the memory footprint of Zope will get huge.  There is NO way
around this.  incrimentally index if you want your process to stay small.
parent 3db0ffa9
...@@ -274,7 +274,7 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -274,7 +274,7 @@ class Catalog(Persistent, Acquisition.Implicit):
# the cataloging API # the cataloging API
def catalogObject(self, object, uid): def catalogObject(self, object, uid, threshold=None):
""" """
Adds an object to the Catalog by iteratively applying it Adds an object to the Catalog by iteratively applying it
...@@ -304,7 +304,7 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -304,7 +304,7 @@ class Catalog(Persistent, Acquisition.Implicit):
total = 0 total = 0
for x in self.indexes.values(): for x in self.indexes.values():
if hasattr(x, 'index_object'): if hasattr(x, 'index_object'):
blah = x.index_object(i, object) blah = x.index_object(i, object, threshold)
__traceback_info__=(`total`, `blah`) __traceback_info__=(`total`, `blah`)
total = total + blah total = total + blah
......
...@@ -159,7 +159,7 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit): ...@@ -159,7 +159,7 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
self.id=id self.id=id
self.title=title self.title=title
self.threshold = 1000 self.threshold = 1000
self.total = 0 self._v_total = 0
self._catalog = Catalog() self._catalog = Catalog()
self._catalog.addColumn('id') self._catalog.addColumn('id')
...@@ -176,7 +176,17 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit): ...@@ -176,7 +176,17 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
self._catalog.addColumn('summary') self._catalog.addColumn('summary')
self._catalog.addIndex('PrincipiaSearchSource', 'TextIndex') self._catalog.addIndex('PrincipiaSearchSource', 'TextIndex')
def manage_edit(self, threshold=1000, REQUEST=None):
""" edit the catalog """
self.threshold = threshold
message = "Object changed"
return self.manage_main(self, REQUEST,
manage_tabs_message=message)
def manage_catalogObject(self, REQUEST, urls=None, blah=None): def manage_catalogObject(self, REQUEST, urls=None, blah=None):
""" index all Zope objects that 'urls' point to """ """ index all Zope objects that 'urls' point to """
...@@ -251,7 +261,6 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit): ...@@ -251,7 +261,6 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
""" Find object according to search criteria and Catalog them """ Find object according to search criteria and Catalog them
""" """
results = self.ZopeFind(REQUEST.PARENTS[1], results = self.ZopeFind(REQUEST.PARENTS[1],
obj_metatypes=obj_metatypes, obj_metatypes=obj_metatypes,
obj_ids=obj_ids, obj_ids=obj_ids,
...@@ -309,10 +318,15 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit): ...@@ -309,10 +318,15 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
def catalog_object(self, obj, uid): def catalog_object(self, obj, uid):
""" wrapper around catalog """ """ wrapper around catalog """
self.total = self.total + self._catalog.catalogObject(obj, uid) if not hasattr(self, '_v_total'):
if self.total > self.threshold: self._v_total = 0
self._v_total = (self._v_total +
self._catalog.catalogObject(obj, uid, self.threshold))
if self._v_total > self.threshold:
print 'commiting in ZCatalog'
get_transaction().commit(1) get_transaction().commit(1)
self.total = 0 self._v_total = 0
def uncatalog_object(self, uid): def uncatalog_object(self, uid):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment