Created
May 12, 2014 21:37
-
-
Save etscrivner/986adaa563ead197293b to your computer and use it in GitHub Desktop.
This file contains 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 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