cmlenz@820: from datetime import datetime cmlenz@820: cmlenz@820: cmlenz@820: class Link(object): cmlenz@820: cmlenz@820: def __init__(self, username, url, title): cmlenz@820: self.username = username cmlenz@820: self.url = url cmlenz@820: self.title = title cmlenz@820: self.time = datetime.utcnow() cmlenz@820: self.id = hex(hash(tuple([username, url, title, self.time])))[2:] cmlenz@820: self.comments = [] cmlenz@820: cmlenz@820: def __repr__(self): cmlenz@820: return '<%s %r>' % (type(self).__name__, self.title) cmlenz@820: cmlenz@820: def add_comment(self, username, content): cmlenz@820: comment = Comment(username, content) cmlenz@820: self.comments.append(comment) cmlenz@820: return comment cmlenz@820: cmlenz@820: cmlenz@820: class Comment(object): cmlenz@820: cmlenz@820: def __init__(self, username, content): cmlenz@820: self.username = username cmlenz@820: self.content = content cmlenz@820: self.time = datetime.utcnow() cmlenz@820: cmlenz@820: def __repr__(self): cmlenz@820: return '<%s by %r>' % (type(self).__name__, self.username)