[csw-devel] SF.net SVN: gar:[21932] csw/mgar/gar/v2/lib/web/pkgdb_web.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sat Sep 14 19:22:17 CEST 2013
Revision: 21932
http://gar.svn.sourceforge.net/gar/?rev=21932&view=rev
Author: wahwah
Date: 2013-09-14 17:22:17 +0000 (Sat, 14 Sep 2013)
Log Message:
-----------
pkgdb: Throw a 404 for bad catrel, arch, osrel
The previous behavior was to throw a 500, but a 404 response is a better one.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/web/pkgdb_web.py
Modified: csw/mgar/gar/v2/lib/web/pkgdb_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/pkgdb_web.py 2013-09-14 16:01:42 UTC (rev 21931)
+++ csw/mgar/gar/v2/lib/web/pkgdb_web.py 2013-09-14 17:22:17 UTC (rev 21932)
@@ -224,8 +224,11 @@
class CatalogDetail(object):
def GET(self, catrel_name, arch_name, osrel_name):
cat_name = " ".join((catrel_name, arch_name, osrel_name))
- sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
- osrel_name, arch_name, catrel_name)
+ try:
+ sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
+ osrel_name, arch_name, catrel_name)
+ except sqlobject.main.SQLObjectNotFound:
+ raise web.notfound()
t2 = time.time()
pkgs = list(models.GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel))
t3 = time.time()
@@ -342,8 +345,11 @@
class RestCatalogDetail(object):
def GET(self, catrel_name, arch_name, osrel_name):
- sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
- osrel_name, arch_name, catrel_name)
+ try:
+ sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
+ osrel_name, arch_name, catrel_name)
+ except sqlobject.main.SQLObjectNotFound:
+ raise web.notfound()
pkgs = list(models.GetCatPackagesResult(sqo_osrel, sqo_arch, sqo_catrel))
if not len(pkgs):
raise web.notfound()
@@ -513,8 +519,11 @@
def GET(self, catrel_name, arch_name, osrel_name, pkgname):
"""Get a srv4 reference by catalog ane pkgname."""
configuration.SetUpSqlobjectConnection()
- sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
- osrel_name, arch_name, catrel_name)
+ try:
+ sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
+ osrel_name, arch_name, catrel_name)
+ except sqlobject.main.SQLObjectNotFound:
+ raise web.notfound()
join = [
sqlbuilder.INNERJOINOn(None,
models.Srv4FileInCatalog,
@@ -608,8 +617,11 @@
catalogname version_string pkgname
basename md5_sum size deps category i_deps
"""
- sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
- osrel_name, arch_name, catrel_name)
+ try:
+ sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
+ osrel_name, arch_name, catrel_name)
+ except sqlobject.main.SQLObjectNotFound:
+ raise web.notfound()
rows = list(models.GetCatalogGenerationResult(sqo_osrel, sqo_arch, sqo_catrel))
def GenCatalogEntry(row):
i_deps = cjson.decode(row[7])
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