Created
September 6, 2013 19:12
-
-
Save thequbit/6468536 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 BlogModel(Base): | |
__tablename__ = 'blogs' | |
id = Column(Integer, primary_key=True) | |
title = Column(Text) | |
posted = Column(DateTime) | |
content = Column(Text) | |
def __init__(self,title,posted,content): | |
self.title = title | |
self.posted = posted | |
self.content = content | |
def _json(self): | |
return { | |
"id" : self.id, | |
"title" : self.title.encode('utf-8'), | |
"posted" : self.__prettydt().encode('utf-8'), | |
"content" : self.content.encode('utf-8') | |
} | |
def __prettydt(self): | |
if self.posted is None: | |
return None | |
return "{0} at {1}".format(self.posted.strftime("%Y-%m-%d"), self.posted.strftime("%H:%M:%S")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment