[rhmessaging-commits] rhmessaging commits: r1776 - mgmt/cumin/python/wooly.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Mar 19 10:10:48 EDT 2008


Author: justi9
Date: 2008-03-19 10:10:48 -0400 (Wed, 19 Mar 2008)
New Revision: 1776

Modified:
   mgmt/cumin/python/wooly/resources.py
Log:
bz437961 - Check a whitelist of resource files before trying to serve
them.
 


Modified: mgmt/cumin/python/wooly/resources.py
===================================================================
--- mgmt/cumin/python/wooly/resources.py	2008-03-19 13:31:48 UTC (rev 1775)
+++ mgmt/cumin/python/wooly/resources.py	2008-03-19 14:10:48 UTC (rev 1776)
@@ -53,21 +53,23 @@
 class ResourceFinder(object):
     def __init__(self):
         self.dirs = list()
+        self.whitelists = dict() # dir => (name1, name2, ...)
 
     def add_dir(self, dir):
         self.dirs.append(dir)
+        self.whitelists[dir] = set(os.listdir(dir))
 
     def find(self, name):
         file = None
 
         for dir in self.dirs:
-            try:
-                path = os.path.join(dir, name)
+            whitelist = self.whitelists[dir]
 
-                #print "Looking for resource '%s'" % path
+            if name in whitelist:
+                try:
+                    path = os.path.join(dir, name)
+                    file = open(path, "r")
+                except IOError:
+                    pass
 
-                file = open(path, "r")
-            except IOError:
-                pass
-
         return file




More information about the rhmessaging-commits mailing list