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)
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)
def linkval(self, path): if not utils.goodpath(path): return None fpath = join2(self.root, path) st = self.getStat(fpath) if not stat_islink(st): return None return os.readlink(fpath)
def get_page_dubious(self, path): # fast-path a certain amount of flailing. if path in self.pcache: return self.pcache[path] # No hit, go the full nine yards. if not utils.goodpath(path): return None return self.get_page(path)
def page_ok(self): code = 404 if utils.boguspath(self.page.path): error = "badrequest" elif not utils.goodpath(self.page.path): error = "nopage" elif not self.page.exists(): error = "nopage" elif not self.page.displayable(): code = 503 if self.page.inconsistent(): error = "inconsistpage" else: error = "badpage" else: return True self.error(error, code) return False
def validname(self, relname): if relname == '': return True return utils.goodpath(relname)