Browse files

Support for pyramid 1.3: use pserve/pcreate instead of paster mozilla…

  • Loading branch information...
1 parent 2a07bae commit c681f65a91f7a13822f82b5118afa482eeaf9be9 Ymage committed Apr 8, 2012
View
2 MANIFEST.in 100644 → 100755
@@ -1,3 +1,3 @@
include *.txt
include *.rst
-recursive-include cornice/template *.*
+recursive-include cornice/scaffolds *.*
View
17 cornice/scaffolds/__init__.py
@@ -0,0 +1,17 @@
+try: # pyramid 1.0.X
+ # "pyramid.paster.paste_script..." doesn't exist past 1.0.X
+ from pyramid.paster import paste_script_template_renderer
+ from pyramid.paster import PyramidTemplate
+except ImportError:
+ try: # pyramid 1.1.X, 1.2.X
+ # trying to import "paste_script_template_renderer" fails on 1.3.X
+ from pyramid.scaffolds import paste_script_template_renderer
+ from pyramid.scaffolds import PyramidTemplate
+ except ImportError: # pyramid >=1.3a2
+ paste_script_template_renderer = None
+ from pyramid.scaffolds import PyramidTemplate
+
+class CorniceTemplate(PyramidTemplate):
+ _template_dir = 'cornice'
+ summary = "A Cornice application"
+ template_renderer = staticmethod(paste_script_template_renderer)
View
21 cornice/template/cornice/+package+.ini_tmpl → cornice/scaffolds/cornice/+package+.ini_tmpl 100644 → 100755
@@ -1,8 +1,5 @@
-[pipeline:main]
-pipeline = pyramidapp
-
-[app:pyramidapp]
-use = egg:${package}
+[app:main]
+use = egg:{{package}}
pyramid.reload_templates = true
pyramid.debug_authorization = false
@@ -12,12 +9,14 @@ pyramid.debug_templates = true
pyramid.default_locale_name = en
[server:main]
-use = egg:Paste#http
+use = egg:waitress#main
host = 0.0.0.0
-port = 5000
+port = 6543
+
+# Begin logging configuration
[loggers]
-keys = root, demoapp
+keys = root, {{package}}
[handlers]
keys = console
@@ -29,10 +28,10 @@ keys = generic
level = INFO
handlers = console
-[logger_demoapp]
+[logger_{{package}}]
level = DEBUG
handlers =
-qualname = demoapp
+qualname = {{package}}
[handler_console]
class = StreamHandler
@@ -42,3 +41,5 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
+
+# End logging configuration
View
2 ...mplate/cornice/+package+/__init__.py_tmpl → ...ffolds/cornice/+package+/__init__.py_tmpl 100644 → 100755
@@ -6,5 +6,5 @@ from pyramid.config import Configurator
def main(global_config, **settings):
config = Configurator(settings=settings)
config.include("cornice")
- config.scan("${package}.views")
+ config.scan("{{package}}.views")
return config.make_wsgi_app()
View
0 .../template/cornice/+package+/views.py_tmpl → ...scaffolds/cornice/+package+/views.py_tmpl 100644 → 100755
File renamed without changes.
View
4 cornice/scaffolds/cornice/README.rst_tmpl
@@ -0,0 +1,4 @@
+Documentation
+=============
+
+Put a brief description of '{{project}}'.
View
12 cornice/template/cornice/setup.py_tmpl → cornice/scaffolds/cornice/setup.py_tmpl 100644 → 100755
@@ -9,9 +9,9 @@ with open(os.path.join(here, 'README.rst')) as f:
README = f.read()
-setup(name=${repr(project)},
+setup(name='{{project}}',
version=0.1,
- description="${description|nothing}",
+ description='{{project}}',
long_description=README,
classifiers=[
"Programming Language :: Python",
@@ -20,16 +20,16 @@ setup(name=${repr(project)},
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application"
],
keywords="web services",
- author=${repr(author)|empty},
- author_email="${author} -at- example.com",
- url="http://example.com",
+ author='',
+ author_email='',
+ url='',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=['cornice', 'PasteScript'],
entry_points = """\
[paste.app_factory]
- main = ${package}:main
+ main = {{package}}:main
""",
paster_plugins=['pyramid'],
)
View
17 cornice/template/__init__.py
@@ -1,17 +0,0 @@
-from paste.script.templates import Template, var
-
-vars = [
- var('appname', 'Application name'),
- var('description', 'One-line description of the project'),
- var('author', 'Author name')]
-
-
-class AppTemplate(Template):
-
- _template_dir = 'cornice'
- summary = "A Cornice application"
- vars = vars
-
- def post(self, command, output_dir, vars):
- if command.verbose:
- print('Generating Application...')
View
4 cornice/template/cornice/README.rst_tmpl
@@ -1,4 +0,0 @@
-Documentation
-=============
-
-Put a brief description of ${repr(project)}.
View
2 docs/source/quickstart.rst
@@ -11,7 +11,7 @@ To use Cornice, install it::
That'll give you a Paster template to use::
- $ paster create -t cornice project
+ $ pcreate -t cornice project
...
The template creates a working Cornice application.
View
44 docs/source/tutorial.rst 100644 → 100755
@@ -51,42 +51,36 @@ Create a new directory and a virtualenv in it::
Once you have it, install Cornice in it with Pip::
- $ bin/pip install Cornice
+ $ bin/pip install cornice
Cornice provides a Paster Template you can use to create a new
application::
- $ bin/paster create -t cornice messaging
- Selected and implied templates:
- cornice#cornice A Cornice application
-
- Variables:
- egg: messaging
- package: messaging
- project: messaging
- Enter appname (Application name) ['']: Messaging
- Enter description (One-line description of the project) ['']: A simple messaging service.
- Enter author (Author name) ['']: Tarek
- Creating template cornice
- ...
- Generating Application...
- Running python2.7 setup.py egg_info
-
+ $ bin/pcreate -t cornice messaging
+ Creating directory <...path ...>/messaging
+ Recursing into +package+
+ Creating <...path ...>/messaging/messaging/
+ Copying __init__.py_tmpl to <...path ...>/messaging/messaging/__init__.py
+ Copying views.py_tmpl to <...path ...>/messaging/messaging/views.py
+ Copying +package+.ini_tmpl to <...path ...>/messaging/messaging.ini
+ Copying README.rst_tmpl to <...path ...>/messaging/README.rst
+ Copying setup.py_tmpl to <...path ...>/messaging/setup.py
+ Welcome to Pyramid. Sorry for the convenience.
Once your application is generated, go there and call *develop* against it::
$ cd messaging
$ ../bin/python setup.py develop
...
-The application can now be launched via Paster, it provides a default "Hello"
+The application can now be launched via embedded Pyramid pserve, it provides a default "Hello"
service check::
- $ ../bin/paster serve messaging.ini
+ $ ../bin/pserve messaging.ini
Starting server in PID 7618.
- serving on 0.0.0.0:5000 view at http://127.0.0.1:5000
+ serving on 0.0.0.0:6543 view at http://127.0.0.1:6543
-Once the application is running, visit http://127.0.0.1:5000 in your browser or
+Once the application is running, visit http://127.0.0.1:6543 in your browser or
Curl and make sure you get::
{'Hello': 'World'}
@@ -200,19 +194,19 @@ mapping, and that will return a 400 with the errors.
Let's try our application so far with CURL::
- $ curl http://localhost:5000/users
+ $ curl http://localhost:6543/users
{"status": "error", "errors": [{"location": "header",
"name": "X-Messaging-Token",
"description": "No token"}]}
- $ curl -X PUT http://localhost:5000/users -d 'tarek'
+ $ curl -X PUT http://localhost:6543/users -d 'tarek'
{"token": "tarek-a15fa2ea620aac8aad3e1b97a64200ed77dc7524"}
- $ curl http://localhost:5000/users -H "X-Messaging-Token:tarek-a15fa2ea620aac8aad3e1b97a64200ed77dc7524"
+ $ curl http://localhost:6543/users -H "X-Messaging-Token:tarek-a15fa2ea620aac8aad3e1b97a64200ed77dc7524"
{'users': ['tarek']}
- $ curl -X DELETE http://localhost:5000/users -H "X-Messaging-Token:tarek-a15fa2ea620aac8aad3e1b97a64200ed77dc7524"
+ $ curl -X DELETE http://localhost:6543/users -H "X-Messaging-Token:tarek-a15fa2ea620aac8aad3e1b97a64200ed77dc7524"
{'Goodbye': 'tarek}
View
20 examples/messaging/messaging.ini 100644 → 100755
@@ -1,7 +1,4 @@
-[pipeline:main]
-pipeline = pyramidapp
-
-[app:pyramidapp]
+[app:main]
use = egg:messaging
pyramid.reload_templates = true
@@ -12,13 +9,14 @@ pyramid.debug_templates = true
pyramid.default_locale_name = en
[server:main]
-use = egg:Paste#http
+use = egg:waitress#main
host = 0.0.0.0
-port = 5000
-use_threadpool = False
+port = 6543
+
+# Begin logging configuration
[loggers]
-keys = root, demoapp
+keys = root, messaging
[handlers]
keys = console
@@ -30,10 +28,10 @@ keys = generic
level = INFO
handlers = console
-[logger_demoapp]
+[logger_messaging]
level = DEBUG
handlers =
-qualname = demoapp
+qualname = messaging
[handler_console]
class = StreamHandler
@@ -43,3 +41,5 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
+
+# End logging configuration
View
11 examples/messaging/setup.py 100644 → 100755
@@ -11,17 +11,18 @@
setup(name='messaging',
version=0.1,
- description="sqd",
+ description='messaging',
long_description=README,
classifiers=[
"Programming Language :: Python",
"Framework :: Pylons",
"Topic :: Internet :: WWW/HTTP",
- "Topic :: Internet :: WWW/HTTP :: WSGI :: Application"],
+ "Topic :: Internet :: WWW/HTTP :: WSGI :: Application"
+ ],
keywords="web services",
- author='qd',
- author_email="qd -at- example.com",
- url="http://example.com",
+ author='',
+ author_email='',
+ url='',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
View
10 setup.py 100644 → 100755
@@ -9,23 +9,23 @@
with open(os.path.join(here, 'CHANGES.txt')) as f:
CHANGES = f.read()
-
requires = ['pyramid', 'coverage', 'simplejson',
'docutils', 'unittest2', 'Sphinx',
- 'webtest', 'Paste', 'PasteScript']
+ 'webtest']
test_requires = requires + ['colander']
entry_points = """\
[paste.paster_create_template]
-cornice=cornice.template:AppTemplate
+cornice=cornice.scaffolds:CorniceTemplate
+[pyramid.scaffold]
+cornice=cornice.scaffolds:CorniceTemplate
"""
package_data = {
- "cornice.template":
+ "cornice.scaffolds":
["cornice/*.*",
"cornice/+package+/*.*"]}
-
setup(name='cornice',
version='0.9',
description='Define Web Services in Pyramid.',

0 comments on commit c681f65

Please sign in to comment.