From: <al...@us...> - 2010-03-06 01:40:18
|
Revision: 13909 http://translate.svn.sourceforge.net/translate/?rev=13909&view=rev Author: alaaosh Date: 2010-03-06 01:40:12 +0000 (Sat, 06 Mar 2010) Log Message: ----------- new methods for mass loading units by id from database Modified Paths: -------------- src/trunk/Pootle/local_apps/pootle_store/models.py Modified: src/trunk/Pootle/local_apps/pootle_store/models.py =================================================================== --- src/trunk/Pootle/local_apps/pootle_store/models.py 2010-03-06 01:39:19 UTC (rev 13908) +++ src/trunk/Pootle/local_apps/pootle_store/models.py 2010-03-06 01:40:12 UTC (rev 13909) @@ -460,6 +460,18 @@ self.state = PARSED self.save() + def require_dbid_index(self, update=False): + """build a quick mapping index between unit ids and database ids""" + if update or not hasattr(self, "dbid_index"): + self.dbid_index = dict(self.units.values_list('unitid', 'id')) + + def findid_bulk(self, ids): + chunks = 200 + for i in xrange(0, len(ids), chunks): + units = self.units.filter(id__in=ids[i:i+chunks]) + for unit in units.iterator(): + yield unit + @commit_on_success def update(self): """update db with units from file""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |