by Dylan Jay
Zope => Zope2
Zope2 => Zope3 begat BlueBreem
BlueBreem => ZTK
ZTK => Repoze.BFG (inspired partially by Django)
Repoze.BFG => Pyramid
RoR possibly begat:
- Django
- Pylons
- TurboGears
- Karl Project
- juice.to
Here we go:
| Pyramid | Django | Plone |
|---|---|---|
| Not opinionated | Opinionated | Structured CMS |
| Very simple | Simple | Complex |
| No DB | ORM | Custom DB |
from paste.httpserver import serve
from pyramid.configuration import Configuration
from pyramid.response import Response
def hello_world(context, request):
return Response('Hello world')
config.add_route('myroute', 'me/{one}')
config.add_view(hello_world, route_name='myroute')
class MyView(object):
""" So much more obvious than Django CBVs!"""
def __init__(self, request):
# something here I didn't write down
def __call__(self):
# why doesn't Django do this?
raise HttpFound('stuff')
from pyramid.view import view_config
@view_config(renderer="json")
def hello_worldrequest):
return dict(content="hello")
All described here: http://docs.pylonsproject.org/projects/pyramid_zcml/en/latest/zcml/view.html
# TODO - add example
config.add_view(myview, name='my-view.html', )
See the fun of:
class Blog(object):
pass
blog = Blog()
blog.__acl__ = [
(Allow, Everyone, 'view'),
(Allow, Editors, 'edit'),
(Allow, Editors, 'delete'),
]