This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InlineToggleMixIn(object): | |
""" | |
Allows details=<resource> querystring param to toggle whether to return resource uri or full details | |
""" | |
# based on handy dehydrate_related from | |
# http://chrismeyers.org/2012/06/25/tastypie-inline-aka-nested-fulltrue-embedded-relationship-dynamically-via-get-parameter/ | |
# Be careful not to create an infinite loop from having multiple resources that reference each other using this | |
# and requesting details on both of them | |
def dehydrate_related(self, bundle, related_resource): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from optparse import OptionParser | |
import re | |
# The book Programming Pearls has an excercise to code | |
# a simple algorithm for taking numbers pressed on a | |
# phone keypad and returning the names from a directory | |
# that the caller may have been looking for. The book | |
# is really aimed at C and C++, but I'm doing some of these | |
# in Python since that's what I mostly work in these days | |
# and am building my skills in. |
NewerOlder