Revert "Eliminate make_map in favor of a simpler map property."
authorEvan Broder <broder@mit.edu>
Sat, 7 Mar 2009 02:53:39 +0000 (21:53 -0500)
committerEvan Broder <broder@mit.edu>
Sat, 7 Mar 2009 02:53:39 +0000 (21:53 -0500)
This reverts commit ca61e30d8f2b2a794374ab3f424df9d5337e778a.

As much as I like using the property instead of the function, it's way
more inefficient to generate the map every time it's accessed. Plus,
you need to seed the map with the controller list, which obviously
wouldn't stick.

I'd switch to using a memoization function of some sort or another,
but Python seems to have utterly failed to standardize on one.

routefs/__init__.py
routefs/dictfs.py
routefs/examples/homefs.py
routefs/examples/pyhesiodfs.py

index 8d620e6..a9a9144 100644 (file)
@@ -43,13 +43,13 @@ class RouteFS(fuse.Fuse):
     def __init__(self, *args, **kwargs):
         super(RouteFS, self).__init__(*args, **kwargs)
         
+        self.map = self.make_map()
         self.map.create_regs(self.controllers)
-    
-    @property
-    def map(self):
+        
+    def make_map(self):
         """
-        This property should be overridden by descendents of RouteFS
-        to define the routing for the filesystem
+        This method should be overridden by descendents of RouteFS to
+        define the routing for the filesystem
         """
         m = routes.Mapper()
         
index 9b88485..77baf63 100644 (file)
@@ -24,8 +24,7 @@ class DictFS(routefs.RouteFS):
         """
         return dict()
     
-    @property
-    def map(self):
+    def make_map(self):
         m = Mapper()
         
         m.connect('*path', controller='handler')
index 1ed6e3d..1666fdd 100755 (executable)
@@ -17,9 +17,8 @@ class HomeFS(routefs.RouteFS):
     def __init__(self, *args, **kwargs):
         super(HomeFS, self).__init__(*args, **kwargs)
         self.cache = {}
-
-    @property
-    def map(self):
+    
+    def make_map(self):
         m = Mapper()
         m.connect('', controller='getList')
         m.connect(':action', controller='getUser')
index c9c526e..880dbb4 100755 (executable)
@@ -12,8 +12,7 @@ class PyHesiodFS(routefs.RouteFS):
         
         self.cache = {}
     
-    @property
-    def map(self):
+    def make_map(self):
         m = Mapper()
         m.connect('', controller='getList')
         m.connect('README.txt', controller='getReadme')