예제 #1
0
파일: storage.py 프로젝트: siebenmann/dwiki
	def validate_quad(self, zone, host, path, key):
		if not self.validname(path) or \
		   '/' in key or '/' in zone or '/' in host or \
		   not utils.good_path_elem(host) or \
		   not utils.good_path_elem(zone) or \
		   not utils.good_path_elem(key):
			raise derrors.CacheKeyErr("bad zone / host / path / key in cachestore: '%s' '%s' '%s' '%s'" % (zone, host, path, key))
예제 #2
0
파일: storage.py 프로젝트: samveen/dwiki
 def validate_quad(self, zone, host, path, key):
     if not self.validname(path) or \
        '/' in key or '/' in zone or '/' in host or \
        not utils.good_path_elem(host) or \
        not utils.good_path_elem(zone) or \
        not utils.good_path_elem(key):
         raise derrors.CacheKeyErr(
             "bad zone / host / path / key in cachestore: '%s' '%s' '%s' '%s'"
             % (zone, host, path, key))
예제 #3
0
파일: storage.py 프로젝트: siebenmann/dwiki
	def children(self, path):
		if not utils.goodpath(path):
			# With an iterator, this yields de nada
			return
		if path == '':
			spath = self.root
		else:
			spath = join2(self.root, path)
		pdirs = [spath,]
		rlen = len(self.root)+1
		while pdirs:
			wd = pdirs.pop()
			try:
				names = os.listdir(wd)
			except EnvironmentError:
				continue
			for name in names:
				if not utils.good_path_elem(name):
					continue
				cn = join2(wd, name)
				st = os.lstat(cn)
				self.stcache[cn] = st
				if stat.S_ISDIR(st.st_mode):
					pdirs.append(cn)
				elif stat.S_ISREG(st.st_mode):
					cn = cn[rlen:]
					# cn is guaranteed to be non-null.
					# we can only get here if it's a
					# regular file, and if it's a
					# regular file it must be inside
					# the root, which is a directory.
					yield (st.st_mtime, cn)
예제 #4
0
파일: storage.py 프로젝트: samveen/dwiki
 def children(self, path):
     if not utils.goodpath(path):
         # With an iterator, this yields de nada
         return
     if path == '':
         spath = self.root
     else:
         spath = join2(self.root, path)
     pdirs = [
         spath,
     ]
     rlen = len(self.root) + 1
     while pdirs:
         wd = pdirs.pop()
         try:
             names = os.listdir(wd)
         except EnvironmentError:
             continue
         for name in names:
             if not utils.good_path_elem(name):
                 continue
             cn = join2(wd, name)
             st = os.lstat(cn)
             self.stcache[cn] = st
             if stat.S_ISDIR(st.st_mode):
                 pdirs.append(cn)
             elif stat.S_ISREG(st.st_mode):
                 cn = cn[rlen:]
                 # cn is guaranteed to be non-null.
                 # we can only get here if it's a
                 # regular file, and if it's a
                 # regular file it must be inside
                 # the root, which is a directory.
                 yield (st.st_mtime, cn)
예제 #5
0
파일: storage.py 프로젝트: siebenmann/dwiki
	def fill(self):
		if self._state != None:
			return
		try:
			self.fstore = [x for x in os.listdir(self.name)
				       if utils.good_path_elem(x)]
			self.fstore.sort()
			self._state = sGood
		except EnvironmentError:
			self._state = sBad
예제 #6
0
파일: storage.py 프로젝트: samveen/dwiki
 def fill(self):
     if self._state != None:
         return
     try:
         self.fstore = [
             x for x in os.listdir(self.name) if utils.good_path_elem(x)
         ]
         self.fstore.sort()
         self._state = sGood
     except EnvironmentError:
         self._state = sBad