Skip to main content

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, Node, branch

USERS = {...}


class Root(Root):
    """Root resource for Pyramid traversal."""
    users = branch('UserCollection')


class UserCollection(Node):
    """User collection, for listings, or loading single users."""
    __child_cls__ = 'User'

    def __load__(self, key):
        """Returns dict with attributes to create a child node from."""
        return {'user': USERS[key]}  # Load user or raise KeyError.


class User(Node):
    """User resource, a single loaded user."""
    gallery = branch('UserGallery', aliases=['images'])


class UserGallery(Node):
    """Gallery of images posted by a user.

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

Download files

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

Source Distribution

kalpa-0.5.1.tar.gz (10.7 kB view details)

Uploaded Source

File details

Details for the file kalpa-0.5.1.tar.gz.

File metadata

  • Download URL: kalpa-0.5.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for kalpa-0.5.1.tar.gz
Algorithm Hash digest
SHA256 ec637642e58aa1cd6534fc307d20a6388c193a2a2bbb41fe1cd33b862c9146aa
MD5 6641b539cd6fef6522b28a4cc543e0d7
BLAKE2b-256 2d67f494c820a2a18ce3499d8d7e3277232b76d8f1ed3d9a7c3820145390e3d1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.1 This release

1 file

0.5.0

1 file

0.4

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page