tweetcast/server/tweetcast-gevent.py
changeset 309 e26d4354b578
parent 307 6872c6aac6d6
--- a/tweetcast/server/tweetcast-gevent.py	Mon Oct 10 11:55:03 2011 +0200
+++ b/tweetcast/server/tweetcast-gevent.py	Mon Oct 10 15:24:12 2011 +0200
@@ -24,21 +24,33 @@
 	user_id = Column(Integer, ForeignKey('tweet_user.id'))
 	user = relationship("User", backref="tweets")
 	
-	def __repr__(self):
-		return anyjson.serialize({
+	def jsondict(self):
+		return {
 			"id" : str(self.id),
 			"created_at" : str(self.created_at),
 			"text" : self.text,
-			"user_id" : self.user_id,
-			"screen_name" : self.user.screen_name
-		})
+			"user" : self.user.jsondict()
+		}
+	
+	def __repr__(self):
+		return anyjson.serialize(self.jsondict())
 
 class User(Base):
 	__tablename__ = "tweet_user"
 	
 	id = Column(BigInteger, primary_key=True, autoincrement=False)
-	created_at = Column(DateTime)
 	screen_name = Column(String, index=True)
+	profile_image_url = Column(String)
+	
+	def jsondict(self):
+		return {
+			"id" : str(self.id),
+			"screen_name" : self.screen_name,
+			"profile_image_url" : self.profile_image_url
+		}
+	
+	def __repr__(self):
+		return anyjson.serialize(self.jsondict())
 
 class TweetCast(object):