SF.net SVN: gar:[23682] csw/mgar/gar/v2/lib/web/releases_web.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Thu May 22 11:55:40 CEST 2014
Revision: 23682
http://sourceforge.net/p/gar/code/23682
Author: wahwah
Date: 2014-05-22 09:55:39 +0000 (Thu, 22 May 2014)
Log Message:
-----------
releases-web: RESTful URL for catalog releases
To make it easier to add and remove catalog releases.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/web/releases_web.py
Modified: csw/mgar/gar/v2/lib/web/releases_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/releases_web.py 2014-05-22 09:55:31 UTC (rev 23681)
+++ csw/mgar/gar/v2/lib/web/releases_web.py 2014-05-22 09:55:39 UTC (rev 23682)
@@ -8,6 +8,7 @@
import hashlib
import logging
import os
+import re
import sys
import tempfile
@@ -548,6 +549,39 @@
raise web.notfound('Stats in the db, but not registered (level 2)')
return ''
+
+class CatalogRelease(object):
+ """Manages catalog releases."""
+ def PUT(self, name):
+ if not re.match(r'', name):
+ raise web.conflict()
+ with Transaction(models.Srv4FileStats) as trans:
+ res = models.CatalogRelease.selectBy(name=name)
+ 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)
+
+ def GET(self, name):
+ try:
+ o = models.CatalogRelease.selectBy(name=name).getOne()
+ return cjson.encode({'name': name, 'obj': unicode(o)})
+ except sqlobject.main.SQLObjectNotFound:
+ raise web.notfound()
+
+
# web.webapi.internalerror = web.debugerror
app = web.application(urls, globals())
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