<s> from os import path <EOL> import shutil <EOL> import tempfile <EOL> try : <EOL> from sh import hovercraft <EOL> hovercraft = hovercraft . bake ( _tty_out = False ) <EOL> except ImportError : <EOL> hovercraft = None <EOL> from django . shortcuts import get_object_or_404 <EOL> from django . http import HttpResponse <EOL> from django . core . cache import cache <EOL> from waliki . models import Page <EOL> from waliki . settings import WALIKI_CACHE_TIMEOUT <EOL> from waliki . acl import permission_required <EOL> @ permission_required ( '<STR_LIT>' ) <EOL> def slides ( request , slug ) : <EOL> page = get_object_or_404 ( Page , slug = slug ) <EOL> cache_key = page . get_cache_key ( '<STR_LIT>' ) <EOL> content = cache . get ( cache_key ) <EOL> if content is None : <EOL> outpath = tempfile . mkdtemp ( ) <EOL> try : <EOL> infile = page . abspath <EOL> template = path . join ( path . dirname ( path . realpath ( __file__ ) ) , '<STR_LIT>' ) <EOL> hovercraft ( '<STR_LIT>' , template , infile , outpath ) <EOL> with open ( path . join ( outpath , '<STR_LIT>' ) ) as f : <EOL> content = f . read ( ) <EOL> cache . set ( cache_key , content , WALIKI_CACHE_TIMEOUT ) <EOL> finally : <EOL> shutil . rmtree ( outpath ) <EOL> return HttpResponse ( content ) </s>
