X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/python-routefs.git/blobdiff_plain/96ed381b595abe28790d066dc6dbdd31702894ae..427878a7a692997d2be7dcfe8051673ec8ec7ba6:/routefs/examples/homefs.py diff --git a/routefs/examples/homefs.py b/routefs/examples/homefs.py index 1666fdd..16c7bda 100755 --- a/routefs/examples/homefs.py +++ b/routefs/examples/homefs.py @@ -8,22 +8,26 @@ will automatically create symlinks from user -> their homedir whenever /home/user is accessed in any way. """ + import pwd -import routefs + from routes import Mapper +import routefs + + class HomeFS(routefs.RouteFS): controllers = ['getList', 'getUser'] def __init__(self, *args, **kwargs): super(HomeFS, self).__init__(*args, **kwargs) self.cache = {} - + def make_map(self): m = Mapper() - m.connect('', controller='getList') - m.connect(':action', controller='getUser') + m.connect('/', controller='getList') + m.connect('/{action}', controller='getUser') return m - + def getUser(self, action, **kwargs): try: if action not in self.cache: @@ -31,9 +35,10 @@ class HomeFS(routefs.RouteFS): return routefs.Symlink(self.cache[action]) except KeyError: return - + def getList(self, **kwargs): return self.cache.keys() + if __name__ == '__main__': routefs.main(HomeFS)