From 3d10ed18cd8baad09cad8ffceb8a1df42d159515 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 22 Aug 2016 23:10:23 -0400 Subject: [PATCH] Update Inside Gratipay to work with Aspen 0.42 --- inside_gratipay.py | 7 ++++++- nav.py | 4 ++-- startapp.py | 19 ++++++------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/inside_gratipay.py b/inside_gratipay.py index da598cd..3296eab 100644 --- a/inside_gratipay.py +++ b/inside_gratipay.py @@ -1,14 +1,19 @@ import os import string import random -from os.path import basename, dirname, join, realpath, isdir +from os.path import basename, dirname from aspen import Response +from aspen.website import Website + import canonizer import gfm from nav import NavItem +website = Website(www_root='www', project_root='.') + + # Manually register markdown renderer to work around Heroku deployment woes. website.renderer_factories['markdown'] = gfm.Factory(website) website.renderer_factories['jinja2'].Renderer.global_context = { diff --git a/nav.py b/nav.py index a410aeb..8169d5d 100644 --- a/nav.py +++ b/nav.py @@ -6,12 +6,12 @@ from os.path import join, realpath, isfile, isdir, basename from aspen import resources -from aspen.resources.static_resource import StaticResource +from aspen.http.resource import Static def get_simplate_context(website, fs): resource = resources.get(website, fs) - return {} if isinstance(resource, StaticResource) else resource.pages[0] + return {} if isinstance(resource, Static) else resource.pages[0] class NavItem(OrderedDict): diff --git a/startapp.py b/startapp.py index c465812..07218bc 100644 --- a/startapp.py +++ b/startapp.py @@ -8,25 +8,18 @@ PORT = 8536 # default/devserver port import sys -from aspen.website import Website - -aspen_config = [ - '--www_root=www/', - '--project_root=.' -] - + for param in sys.argv: if param.startswith('--port'): _, PORT = param.split('=') PORT = int(PORT) - - + + # by WSGI convention, we need to create webapp object # and by default most WSGI servers look for 'application' -application = Website(aspen_config) - +from inside_gratipay import website as application + if __name__ == '__main__': from wsgiref.simple_server import make_server - print("* Running development server on http://%s:%s" % (HOST, PORT)) + print("* Running development server on http://%s:%s" % (HOST or 'localhost', PORT)) make_server(HOST, PORT, application).serve_forever() -