Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Resource baseclasses for traversal in Pyramid

Project Description

Kalpa provides a starting point for resource traversal in Pyramid. It provides two classes for this, a Branch and a Leaf, which allow you to create arbitrary resource trees without the boilerplate.

There is also a Root class for added convenience that accepts a request during initialization. This can be used to create a starting point for Pyramid’s traversal.

from kalpa import Root, Branch, Leaf

USERS = {...}

class UserCollection(Branch):
    """User collection, for listings, or loading single users."""

    def __load__(self, key):
        """Return child resource with requested user included."""
        user = USERS[key]  # Load user or raise KeyError.
        return self._child(key, user=user)

class User(Branch):
    """User resource, a single loaded user."""

@User.attach('gallery', aliases=['images'])
class UserGallery(Leaf):
    """Gallery of images posted by a user.

    Reachable as `/users/:id/gallery` but also `/users/:id/images`.

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(9.2 kB) Copy SHA256 Hash SHA256
py2.py3 Wheel Sep 11, 2017
(7.0 kB) Copy SHA256 Hash SHA256
Source Sep 11, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting