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

Useful utilities for every pyramid app

Project Description

Pyramid Duh

Master Build:
0.1 Build:
Documentation:http://pyramid_duh.readthedocs.org/
Downloads:http://pypi.python.org/pypi/pyramid_duh
Source:https://github.com/stevearc/pyramid_duh

This is just a collection of utilities that I found myself putting into every single pyramid project I made. So now they’re all in one place.

Here’s a quick taste.

Don’t do this:

def register_user(request):
    username = request.POST['username']
    password = request.POST['password']
    birthdate = request.POST['birthdate']

Do this:

@argify(birthdate=date)
def register_user(request, username, password, birthdate):
    ...

What urls does this match?

@view_config(context=Root, name='package')
def get_or_list_packages(request):
    ...

Well, it matches

  • /package
  • /package/
  • /package/1234
  • /package/wait/hold/on
  • /package/this/seems/confusing

Whaaaat? Let’s fix that:

@view_config(context=Root, name='package', subpath=())
def list_packages(request):
    # return a list of packages

@view_config(context=Root, name='package', subpath=('id/*')
def get_package(request):
    package_id = request.named_subpaths['id']
    # fetch a single package

The first one matches

  • /package
  • /package/

The second matches

  • /package/*
  • /package/*/

But that still seems sloppy. You demand consistency!

@view_config(context=Root, name='package', subpath=())
@addslash
def list_packages(request):
    # return a list of packages

@view_config(context=Root, name='package', subpath=('id/*')
@addslash
def get_package(request):
    package_id = request.named_subpaths['id']
    # fetch a single package

Now it’s just /package/ and /package/*/

That’s the sales pitch. Read the docs for more details.

Changelog

0.1.2

  • Bug fix: Fix potential timezone issue when converting unix time to datetime
  • Using the ‘six’ library for python 2/3 compatibility

0.1.1

  • Bug fix: IStaticResource fails to look up self.request if nested 2-deep
  • Bug fix: Name collisions with version_helper.py
  • Bug fix: Subpath glob matching always respects case
  • Feature: @argify works on view classes
  • Feature: @argify can inject types that consume multiple parameters
  • Feature: Parameter types can be a dotted path

0.1.0

  • Package released into the wild
Release History

Release History

This version
History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pyramid_duh-0.1.2-py2.py3-none-any.whl (13.1 kB) Copy SHA256 Checksum SHA256 2.7 Wheel May 9, 2014
pyramid_duh-0.1.2.tar.gz (11.0 kB) Copy SHA256 Checksum SHA256 Source May 9, 2014

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