- Timestamp:
- 12/22/08 13:52:40 (16 years ago)
- Files:
-
- trunk/source/pyhesiodfs/pyHesiodFS.py (modified) (4 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/source/pyhesiodfs/pyHesiodFS.py
- Property svn:executable set to *
r157 r159 17 17 import hesiod 18 18 19 try: 20 from collections import defaultdict 21 except ImportError: 22 class defaultdict(dict): 23 """ 24 A dictionary that automatically will fill in keys that don't exist 25 with the result from some default value factory 26 27 Based on the collections.defaultdict object in Python 2.5 28 """ 29 30 def __init__(self, default_factory): 31 self.default_factory = default_factory 32 super(defaultdict, self).__init__() 33 34 def __getitem__(self, y): 35 if y not in self: 36 self[y] = self.default_factory() 37 return super(defaultdict, self).__getitem__(y) 38 39 def __str__(self): 40 print 'defaultdict(%s, %s)' % (self.default_factory, 41 super(defaultdict, self).__str__()) 42 19 43 new_fuse = hasattr(fuse, '__version__') 20 44 … … 66 90 self.fuse_args.add("volname", "MIT") 67 91 self.fuse_args.add("fsname", "pyHesiodFS") 68 self.mounts = {} 92 self.mounts = defaultdict(dict) 93 94 def _user(self): 95 return fuse.FuseGetContext()['uid'] 69 96 70 97 def getattr(self, path): … … 92 119 93 120 def getCachedLockers(self): 94 return self.mounts .keys()121 return self.mounts[self._user()].keys() 95 122 96 123 def findLocker(self, name): 97 124 """Lookup a locker in hesiod and return its path""" 98 if name in self.mounts :99 return self.mounts[ name]125 if name in self.mounts[self._user()]: 126 return self.mounts[self._user()][name] 100 127 else: 101 128 try: … … 114 141 return None 115 142 else: 116 self.mounts[ name] = pointer['location']143 self.mounts[self._user()][name] = pointer['location'] 117 144 syslog(LOG_INFO, "Mounting "+name+" on "+pointer['location']) 118 145 return pointer['location']