Added a basic project template for Pecan projects. Use "paster create

--template=pecan-base" to use it.
This commit is contained in:
Jonathan LaCour
2010-10-01 17:26:12 -04:00
parent abc1278baf
commit 72c636ca4d
13 changed files with 54 additions and 6 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1,3 +1,4 @@
# -*- Entry points: -*-
[paste.paster_create_template]
pecan-base = templates:NewProjectTemplate

View File

@@ -5,4 +5,5 @@ Kajiki >= 0.2.2
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

View File

@@ -1,2 +1,3 @@
templates
tests
pecan

View File

@@ -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)

View File

@@ -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
""",
)

5
templates/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
from paste.script import templates
class NewProjectTemplate(templates.Template):
summary = 'Template for creating a basic Framework package'
_template_dir = 'project'

View File

View File

@@ -0,0 +1,6 @@
from pecan import expose
class RootController(object):
@expose('kajiki:index.html')
def index(self, name='World'):
return dict(name=name)

View File

@@ -0,0 +1,8 @@
<html>
<head>
<title>Hello, ${name}</title>
</head>
<body>
<h1>Hello, ${name}!</h1>
</body>
</html>

View File

@@ -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'