Skip to content

Instantly share code, notes, and snippets.

@etscrivner
Created May 12, 2014 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etscrivner/986adaa563ead197293b to your computer and use it in GitHub Desktop.
Save etscrivner/986adaa563ead197293b to your computer and use it in GitHub Desktop.
class ListedProduct(object):
def __init__(self, listed_product_tuple):
"""Takes a KeyedTuple and transforms it into a listed product.
:param listed_product_tuple: A KeyedTuple
:type listed_product_tuple: sqlalchemy.KeyedTuple
"""
self.listed_product_tuple
@property
def json(self):
return {
'id': self.listed_product_tuple.ProductListing.listing_id,
'category': self.listed_product_tuple.Categories.name,
# etc...
}
class ProductListing(...):
# ...
@classmethod
def get(cls):
return [ListedProduct(each) for each in cls.big_ole_join()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment