[csw-devel] SF.net SVN: gar:[15944] csw/mgar/gar/v2/lib/web/pkgdb_web.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Oct 21 09:25:35 CEST 2011


Revision: 15944
          http://gar.svn.sourceforge.net/gar/?rev=15944&view=rev
Author:   wahwah
Date:     2011-10-21 07:25:35 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
pkgdb-web: Serve file lists by md5 sums vs REST

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	2011-10-20 21:41:02 UTC (rev 15943)
+++ csw/mgar/gar/v2/lib/web/pkgdb_web.py	2011-10-21 07:25:35 UTC (rev 15944)
@@ -34,6 +34,7 @@
   r'/rest/catalogs/([^/]+)/(sparc|i386)/(SunOS[^/]+)/catalognames/([^/]+)/', 'Srv4ByCatAndCatalogname',
   r'/rest/catalogs/([^/]+)/(sparc|i386)/(SunOS[^/]+)/pkgnames/([^/]+)/', 'Srv4ByCatAndPkgname',
   r'/rest/srv4/([0-9a-f]{32})/', 'RestSrv4Detail',
+  r'/rest/srv4/([0-9a-f]{32})/files/', 'RestSrv4DetailFiles',
 )
 
 # render = web.template.render('templates/')
@@ -282,6 +283,27 @@
       raise web.notfound()
 
 
+class RestSrv4DetailFiles(object):
+
+  def GET(self, md5_sum):
+    ConnectToDatabase()
+    try:
+      pkg = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
+      files = models.CswFile.selectBy(srv4_file=pkg)
+      web.header('Content-type', 'application/x-vnd.opencsw.pkg;type=file-list')
+      web.header('Access-Control-Allow-Origin', '*')
+      def FileDict(file_obj):
+        return {
+            "basename": file_obj.basename,
+            "path": file_obj.path,
+            "line": file_obj.line,
+        }
+      serializable_files = [FileDict(x) for x in files]
+      return json.dumps(serializable_files)
+    except sqlobject.main.SQLObjectNotFound, e:
+      raise web.notfound()
+
+
 class Srv4ByCatAndCatalogname(object):
 
   def GET(self, catrel_name, arch_name, osrel_name, catalogname):

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