当前位置: 首页>>代码示例>>Python>>正文


Python CachingFilePath.restat方法代码示例

本文整理汇总了Python中twext.python.filepath.CachingFilePath.restat方法的典型用法代码示例。如果您正苦于以下问题:Python CachingFilePath.restat方法的具体用法?Python CachingFilePath.restat怎么用?Python CachingFilePath.restat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twext.python.filepath.CachingFilePath的用法示例。


在下文中一共展示了CachingFilePath.restat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: File

# 需要导入模块: from twext.python.filepath import CachingFilePath [as 别名]
# 或者: from twext.python.filepath.CachingFilePath import restat [as 别名]

#.........这里部分代码省略.........
        child = self.putChildren.get(name, None)
        if child: return child

        child_fp = self.fp.child(name)
        if hasattr(self, "knownChildren"):
            if name in self.knownChildren:
                child_fp.existsCached = True
        if child_fp.exists():
            return self.createSimilarFile(child_fp)
        else:
            return None

    def listChildren(self):
        """
        @return: a sequence of the names of all known children of this resource.
        """
        children = self.putChildren.keys()
        if self.fp.isdir():
            children += [c for c in self.fp.listdir() if c not in children]
            self.knownChildren = set(children)
        return children

    def locateChild(self, req, segments):
        """
        See L{IResource}C{.locateChild}.
        """
        # If getChild() finds a child resource, return it
        child = self.getChild(segments[0])
        if child is not None: return (child, segments[1:])

        # If we're not backed by a directory, we have no children.
        # But check for existance first; we might be a collection resource
        # that the request wants created.
        self.fp.restat(False)
        if self.fp.exists() and not self.fp.isdir(): return (None, ())

        # OK, we need to return a child corresponding to the first segment
        path = segments[0]

        if path:
            fpath = self.fp.child(path)
        else:
            # Request is for a directory (collection) resource
            return (self, server.StopTraversal)

        # Don't run processors on directories - if someone wants their own
        # customized directory rendering, subclass File instead.
        if fpath.isfile():
            processor = self.processors.get(fpath.splitext()[1].lower())
            if processor:
                return (
                    processor(fpath.path),
                    segments[1:])

        elif not fpath.exists():
            sibling_fpath = fpath.siblingExtensionSearch(*self.ignoredExts)
            if sibling_fpath is not None:
                fpath = sibling_fpath

        return self.createSimilarFile(fpath.path), segments[1:]

    def renderHTTP(self, req):
        self.fp.changed()
        return super(File, self).renderHTTP(req)

    def render(self, req):
开发者ID:jrossi,项目名称:twext,代码行数:70,代码来源:static.py


注:本文中的twext.python.filepath.CachingFilePath.restat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。