[csw-devel] SF.net SVN: gar:[12131] csw/mgar/gar/v2/lib/python/package_stats.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Thu Dec 30 03:49:59 CET 2010
Revision: 12131
http://gar.svn.sourceforge.net/gar/?rev=12131&view=rev
Author: wahwah
Date: 2010-12-30 02:49:59 +0000 (Thu, 30 Dec 2010)
Log Message:
-----------
checkpkg: Delete old srv4 objects when saving
During SaveStats(), detect a case in which the object is already in the
database, and delete it, together with all dependent objects.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/package_stats.py
Modified: csw/mgar/gar/v2/lib/python/package_stats.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats.py 2010-12-30 02:49:29 UTC (rev 12130)
+++ csw/mgar/gar/v2/lib/python/package_stats.py 2010-12-30 02:49:59 UTC (rev 12131)
@@ -267,6 +267,16 @@
if "revision_info" in parsed_basename:
if "REV" in parsed_basename["revision_info"]:
rev = parsed_basename["revision_info"]["REV"]
+ # If the object already exists in the database, delete it.
+ md5_sum = pkg_stats["basic_stats"]["md5_sum"]
+ try:
+ db_pkg_stats = m.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
+ logging.debug("Destroying %s before saving it again", db_pkg_stats)
+ db_pkg_stats.DeleteAllDependentObjects()
+ db_pkg_stats.destroySelf()
+ except sqlobject.main.SQLObjectNotFound, e:
+ logging.debug("Package %s not present in the db, proceeding with insert.")
+ pass
# Creating the object in the database.
data_obj = m.Srv4FileStatsBlob(
pickle=cPickle.dumps(pkg_stats))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list