SF.net SVN: gar:[23846] csw/mgar/gar/v2/lib
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sun Jul 20 02:07:23 CEST 2014
Revision: 23846
http://sourceforge.net/p/gar/code/23846
Author: wahwah
Date: 2014-07-20 00:07:20 +0000 (Sun, 20 Jul 2014)
Log Message:
-----------
releases-web: Fixes for the transaction support
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/checkpkg_lib.py
csw/mgar/gar/v2/lib/web/releases_web.py
Modified: csw/mgar/gar/v2/lib/python/checkpkg_lib.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_lib.py 2014-07-19 12:21:04 UTC (rev 23845)
+++ csw/mgar/gar/v2/lib/python/checkpkg_lib.py 2014-07-20 00:07:20 UTC (rev 23846)
@@ -1236,5 +1236,6 @@
# Files belonging to this package should not be removed from the catalog
# as the package might be still present in another catalog.
except sqlobject.main.SQLObjectNotFound as e:
- self.logger.debug('The object went away when we were trying to delete it.')
+ self.logger.debug(u'The object %s was not found in %s.',
+ sqo_srv4, catspec)
self.logger.warning(e)
Modified: csw/mgar/gar/v2/lib/web/releases_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/releases_web.py 2014-07-19 12:21:04 UTC (rev 23845)
+++ csw/mgar/gar/v2/lib/web/releases_web.py 2014-07-20 00:07:20 UTC (rev 23846)
@@ -366,12 +366,13 @@
"are not allowed" % osrel_name)
srv4_to_remove = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
c = checkpkg_lib.Catalog()
- c.RemoveSrv4(srv4_to_remove, osrel_name, arch_name, catrel_name)
- msg = ('Package %s / %s removed successfully'
- % (srv4_to_remove.basename, md5_sum))
- response = cjson.encode({'message': msg})
- web.header('Content-Length', len(response))
- return response
+ with Transaction(models.Srv4FileStats) as trans:
+ c.RemoveSrv4(srv4_to_remove, osrel_name, arch_name, catrel_name, trans)
+ msg = ('Package %s / %s removed successfully'
+ % (srv4_to_remove.basename, md5_sum))
+ response = cjson.encode({'message': msg})
+ web.header('Content-Length', len(response))
+ return response
except (
sqlobject.main.SQLObjectNotFound,
@@ -540,13 +541,18 @@
raise web.notacceptable(exc)
def HEAD(self, md5_sum):
+ # Will throw an exception.
+ payload = self.GET(md5_sum)
+ return ''
+
+ def GET(self, md5_sum):
try:
srv4 = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
except sqlobject.main.SQLObjectNotFound:
raise web.notfound('Stats not in the database')
if not srv4.registered_level_two:
raise web.notfound('Stats in the db, but not registered (level 2)')
- return ''
+ return '{"the package is registered"}'
class CatalogRelease(object):
@@ -555,23 +561,25 @@
if not re.match(r'', name):
raise web.conflict()
with Transaction(models.Srv4FileStats) as trans:
- res = models.CatalogRelease.selectBy(name=name)
+ res = models.CatalogRelease.selectBy(name=name, connection=trans)
if res.count():
return cjson.encode('%s already exists' % name)
models.CatalogRelease(name=name, connection=trans)
return cjson.encode('%s has been created' % name)
def DELETE(self, name):
- try:
- o = models.CatalogRelease.selectBy(name=name).getOne()
- except sqlobject.main.SQLObjectNotFound:
- raise web.notfound()
- res = models.Srv4FileInCatalog.select(models.Srv4FileInCatalog.q.catrel==o)
- if res.count():
- # There are pacakges in this catalog. Cannot remove.
- raise web.conflict()
- o.destroySelf()
- return cjson.encode('%s has been deleted' % name)
+ with Transaction(models.Srv4FileStats) as trans:
+ try:
+ o = models.CatalogRelease.selectBy(name=name, connection=trans).getOne()
+ except sqlobject.main.SQLObjectNotFound:
+ raise web.notfound()
+ res = models.Srv4FileInCatalog.select(models.Srv4FileInCatalog.q.catrel==o,
+ connection=trans)
+ if res.count():
+ # There still are packages in this catalog. We cannot remove it.
+ raise web.conflict()
+ o.destroySelf()
+ return cjson.encode('%s has been deleted' % name)
def GET(self, name):
try:
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