Pyramid is a Python web framework that focuses on simplicity, minimalism, and flexibility. It provides tools for URL routing, templating, security, and serving static assets while allowing developers to choose their own persistence and templating systems. Pyramid is influenced by Zope and Pylons but aims to be lightweight, fast, reliable, and Pythonic. It supports a variety of configuration styles and development tools.
2. V鱈ctorFern叩ndezdeAlba
Lead web developer at Barcelona Tech University
Author of Plone 3 Intranets (2010, PacktPub)
Developing Plone sites since 2004
Developing Pyramid applications since its early betas
- /V鱈ctor's Blog @sneridagh
18. Cornice:ARESTframeworkfor
Pyramid
[..]
from cornice import Service
info_desc = """This service is useful to get and set data for a user."""
user_info = Service(name='users', path='/{username}/info',
description=info_desc)
_USERS = defaultdict(dict)
@user_info.get()
def get_info(request):
"""Returns the public information about a **user**.
If the user does not exists, returns an empty dataset.
"""
username = request.matchdict['username']
return _USERS[username]
19. Cornice:ARESTframeworkfor
Pyramid(II)
@user_info.post()
def set_info(request):
"""Set the public information for a **user**.
You have to be that user, and *authenticated*.
Returns *True* or *False*.
"""
username = authenticated_userid(request)
if request.matchdict["username"] != username:
raise Forbidden()
_USERS[username] = request.json_body
return {'success': True}