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