From 72c636ca4d3ef900810b3a97aa4125c8505572bc Mon Sep 17 00:00:00 2001 From: Jonathan LaCour Date: Fri, 1 Oct 2010 17:26:12 -0400 Subject: [PATCH] Added a basic project template for Pecan projects. Use "paster create --template=pecan-base" to use it. --- pecan.egg-info/PKG-INFO | 2 +- pecan.egg-info/SOURCES.txt | 1 + pecan.egg-info/entry_points.txt | 3 ++- pecan.egg-info/requires.txt | 3 ++- pecan.egg-info/top_level.txt | 1 + pecan/pecan.py | 5 ++++- setup.py | 10 ++++++++-- templates/__init__.py | 5 +++++ templates/project/+egg+/__init__.py | 0 templates/project/+egg+/controllers/__init__.py | 0 templates/project/+egg+/controllers/root.py | 6 ++++++ templates/project/+egg+/templates/index.html | 8 ++++++++ templates/project/start.py_tmpl | 16 ++++++++++++++++ 13 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 templates/__init__.py create mode 100644 templates/project/+egg+/__init__.py create mode 100644 templates/project/+egg+/controllers/__init__.py create mode 100644 templates/project/+egg+/controllers/root.py create mode 100644 templates/project/+egg+/templates/index.html create mode 100644 templates/project/start.py_tmpl diff --git a/pecan.egg-info/PKG-INFO b/pecan.egg-info/PKG-INFO index 3e6b2ae..fb21388 100644 --- a/pecan.egg-info/PKG-INFO +++ b/pecan.egg-info/PKG-INFO @@ -2,7 +2,7 @@ Metadata-Version: 1.0 Name: pecan Version: 0.1dev Summary: A WSGI object-dispatching web framework, in the spirit of TurboGears, only much much smaller, with many fewer dependancies. -Home-page: http://sf.net/p/pecan +Home-page: http://github.com/cleverdevil/pecan Author: Jonathan LaCour Author-email: jonathan@cleverdevil.org License: BSD diff --git a/pecan.egg-info/SOURCES.txt b/pecan.egg-info/SOURCES.txt index a4edd69..11a6fe5 100644 --- a/pecan.egg-info/SOURCES.txt +++ b/pecan.egg-info/SOURCES.txt @@ -16,4 +16,5 @@ pecan.egg-info/entry_points.txt pecan.egg-info/requires.txt pecan.egg-info/top_level.txt pecan.egg-info/zip-safe +templates/__init__.py tests/templates/__init__.py \ No newline at end of file diff --git a/pecan.egg-info/entry_points.txt b/pecan.egg-info/entry_points.txt index a184cd0..0dc6953 100644 --- a/pecan.egg-info/entry_points.txt +++ b/pecan.egg-info/entry_points.txt @@ -1,3 +1,4 @@ - # -*- Entry points: -*- + [paste.paster_create_template] + pecan-base = templates:NewProjectTemplate \ No newline at end of file diff --git a/pecan.egg-info/requires.txt b/pecan.egg-info/requires.txt index 20ca926..59c1987 100644 --- a/pecan.egg-info/requires.txt +++ b/pecan.egg-info/requires.txt @@ -5,4 +5,5 @@ Kajiki >= 0.2.2 Mako >= 0.3 py >= 1.3.4 WebTest >= 1.2.2 -Paste >= 1.7.5.1 \ No newline at end of file +Paste >= 1.7.5.1 +PasteScript >= 1.7.3 \ No newline at end of file diff --git a/pecan.egg-info/top_level.txt b/pecan.egg-info/top_level.txt index 288ca7a..e2c770a 100644 --- a/pecan.egg-info/top_level.txt +++ b/pecan.egg-info/top_level.txt @@ -1,2 +1,3 @@ +templates tests pecan diff --git a/pecan/pecan.py b/pecan/pecan.py index 4416b6a..4e421d3 100644 --- a/pecan/pecan.py +++ b/pecan/pecan.py @@ -134,9 +134,12 @@ class Pecan(object): # if this is an HTTP Exception, set it as the response if isinstance(e, exc.HTTPException): state.response = e - + # handle "error" hooks self.handle_hooks('on_error', state, e) + + if not isinstance(e, exc.HTTPException): + raise finally: # handle "after" hooks self.handle_hooks('after', state) diff --git a/setup.py b/setup.py index df64f1c..092d5ab 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,9 @@ import sys, os, py version = '0.1' +# +# integration with py.test for `python setup.py test` +# class PyTest(Command): user_options = [] def initialize_options(self): @@ -13,6 +16,7 @@ class PyTest(Command): import py py.cmdline.pytest(py.std.sys.argv[2:]) + setup( name = 'pecan', version = version, @@ -36,9 +40,11 @@ setup( "Mako >= 0.3", "py >= 1.3.4", "WebTest >= 1.2.2", - "Paste >= 1.7.5.1" + "Paste >= 1.7.5.1", + "PasteScript >= 1.7.3" ], entry_points = """ - # -*- Entry points: -*- + [paste.paster_create_template] + pecan-base = templates:NewProjectTemplate """, ) diff --git a/templates/__init__.py b/templates/__init__.py new file mode 100644 index 0000000..1b3ebfc --- /dev/null +++ b/templates/__init__.py @@ -0,0 +1,5 @@ +from paste.script import templates + +class NewProjectTemplate(templates.Template): + summary = 'Template for creating a basic Framework package' + _template_dir = 'project' \ No newline at end of file diff --git a/templates/project/+egg+/__init__.py b/templates/project/+egg+/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/templates/project/+egg+/controllers/__init__.py b/templates/project/+egg+/controllers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/templates/project/+egg+/controllers/root.py b/templates/project/+egg+/controllers/root.py new file mode 100644 index 0000000..5c404e1 --- /dev/null +++ b/templates/project/+egg+/controllers/root.py @@ -0,0 +1,6 @@ +from pecan import expose + +class RootController(object): + @expose('kajiki:index.html') + def index(self, name='World'): + return dict(name=name) \ No newline at end of file diff --git a/templates/project/+egg+/templates/index.html b/templates/project/+egg+/templates/index.html new file mode 100644 index 0000000..d2a8837 --- /dev/null +++ b/templates/project/+egg+/templates/index.html @@ -0,0 +1,8 @@ + + + Hello, ${name} + + +

Hello, ${name}!

+ + \ No newline at end of file diff --git a/templates/project/start.py_tmpl b/templates/project/start.py_tmpl new file mode 100644 index 0000000..fb4ef5e --- /dev/null +++ b/templates/project/start.py_tmpl @@ -0,0 +1,16 @@ +from pecan import make_app +from ${egg}.controllers.root import RootController + +if __name__ == '__main__': + app = make_app( + RootController(), + static_root='public', + template_path='${egg}/templates' + ) + + print 'Serving on http://0.0.0.0:8080' + from paste import httpserver + try: + httpserver.serve(app, host='0.0.0.0', port=8080) + except KeyboardInterrupt: + print '^C' \ No newline at end of file