Skip to content

Instantly share code, notes, and snippets.

import collections
import re
import routes
from keystone import assignment
from keystone import auth
from keystone import catalog
from keystone.common import controller
from keystone import credential
def _require_single_keyword_arg(self, **kwargs):
provided_params = [name for name, value in kwargs.iteritems() if value]
if not provided_params: raise VE('Something must be passed in')
if len(provided_params) != 1:
msg = _('Only a single keyword arg allowed: received %s') % ', '.join(provided_params)
raise exception.ValidationError(msg)
@dstanek
dstanek / codemash-python-koans.rst
Last active January 6, 2016 21:15
Codemash 2016: Python Koans

Header a

header c

header d ----------

Title

Python Koans - An Introduction To Python

Abstract

Python is a fun, dynamic, flexible language for solving all kinds of problems. It's used everywhere from modest scripts to large systems, powering things like websites, games, film production tools, scientific analysis, and even space programs. Best of all, it's a language that "fits your brain".

This session is a mostly self guided introduction to Python through koans. What’s a koan you ask? It’s a small puzzle or exercise expressed as a test, designed to build your knowledge of the Python syntax and idioms incrementially.

Policy-Endpoint Associations

Create association with endpoint: PUT /OS-ENDPOINT-POLICY/endpoints/{endpoint_id}/policy

Creates an association between the policy and the endpoint. If another association already existed for the specified endpoint, this will replace that association.

Request:

@dstanek
dstanek / di_with_sg.py
Created July 21, 2014 18:39
DI with snake-guice
import abc
class Logger(object):
__metaclass__ abc.ABCMeta
@abstractmethod
def log_it(self, message, *args, **kwargs):
raise NotImplemented
@dstanek
dstanek / di_by_hand.py
Last active August 29, 2015 14:04
DI by hand
import abc
class Logger(object):
__metaclass__ abc.ABCMeta
@abstractmethod
def log_it(self, message, *args, **kwargs):
raise NotImplemented
{
"rules": [
{
"local": {
"user": {
"name": "@@UserName@@"
}
},
"remote": [
{
{
"rules": [
{
"local": {
"user": "name"
},
"remote": [
{
"type": "UserName"
}