Added a basic project template for Pecan projects. Use "paster create
--template=pecan-base" to use it.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
# -*- Entry points: -*-
|
||||
[paste.paster_create_template]
|
||||
pecan-base = templates:NewProjectTemplate
|
||||
|
||||
@@ -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
|
||||
@@ -1,2 +1,3 @@
|
||||
templates
|
||||
tests
|
||||
pecan
|
||||
|
||||
@@ -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)
|
||||
|
||||
10
setup.py
10
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
|
||||
""",
|
||||
)
|
||||
|
||||
5
templates/__init__.py
Normal file
5
templates/__init__.py
Normal 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'
|
||||
0
templates/project/+egg+/__init__.py
Normal file
0
templates/project/+egg+/__init__.py
Normal file
0
templates/project/+egg+/controllers/__init__.py
Normal file
0
templates/project/+egg+/controllers/__init__.py
Normal file
6
templates/project/+egg+/controllers/root.py
Normal file
6
templates/project/+egg+/controllers/root.py
Normal 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)
|
||||
8
templates/project/+egg+/templates/index.html
Normal file
8
templates/project/+egg+/templates/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello, ${name}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, ${name}!</h1>
|
||||
</body>
|
||||
</html>
|
||||
16
templates/project/start.py_tmpl
Normal file
16
templates/project/start.py_tmpl
Normal 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'
|
||||
Reference in New Issue
Block a user