import py def templatepath(request): options = request.get_options() tdir = options.get('templatedir', None) if tdir is None: tpath = appdir() / 'templates' else: tpath = py.path.local(tdir) return tpath def appdir(): return py.magic.autopath().dirpath()