Beispiel #1
0
    def get(self, name, extension=None):
        """ Interface to get a template, possibly loading a compiled template.

            "name" and "extension" indicate the template we're after, which in
            most cases will be "name.extension". If "extension" is None, then
            we look for a template just called "name" with no extension.

            If the file "name.extension" doesn't exist, we look for
            "_generic.extension" as a fallback.
        """
        # default the name to "home"
        if name is None:
            name = 'home'
        elif extension is None and '.' in name:
            # split name
            name, extension = name.split('.')

        # find the source
        src, filename = find_template(self.dir, name, extension)

        # has it changed?
        try:
            stime = os.stat(src)[os.path.stat.ST_MTIME]
        except os.error, error:
            if error.errno != errno.ENOENT:
                raise
Beispiel #2
0
    def get(self, name, extension=None):
        # default the name to "home"
        if name is None:
            name = "home"
        elif extension is None and "." in name:
            # split name
            name, extension = name.split(".")

        src, filename = find_template(self.dir, name, extension)
        return RoundupPageTemplate(self.loader.load(src))