Skip to content

Instantly share code, notes, and snippets.

@thequbit
Created September 6, 2013 19:12
Show Gist options
  • Save thequbit/6468536 to your computer and use it in GitHub Desktop.
Save thequbit/6468536 to your computer and use it in GitHub Desktop.
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