Example #1
0
def chunk(request, chunkpath):
    """
    renders a chunk

    request is the current request object
    chunkpath is the path of the chunk
    """

    context = {
        "chunk": Chunk.get_by_path(chunkpath)
    }
    return RequestContext(request, context)
Example #2
0
    def __inspect_dir(self, sub_path):
        """ inspects a given subpath (generated by os.walk) for templates with chunk tag """

        for file_name in sub_path[2]:
            file_path = "{0}/{1}".format(sub_path[0], file_name)
            fp = file(file_path)
            file_content = fp.read()

            result = self.__class__.pattern.findall(file_content)
            if result:
                for chunk_path in result:
                    try:
                        Chunk.get_by_path(chunk_path)
                    except Chunk.DoesNotExist:
                        chunk = Chunk()
                        chunk.path = chunk_path
                        chunk.content = "This ist a new Chunk. You should edit it."
                        chunk.author = User.objects.all()[0]  # Maybe use a beeter way with settings
                        chunk.save()