Mercurial > genshi > genshi-test
view examples/tutorial/geddit/model.py @ 936:47c83fbdf4d4
Merge r1144 from py3k: Add documentation on upgrading to the Genshi py3k branch.
author | hodgestar |
---|---|
date | Fri, 18 Mar 2011 09:18:59 +0000 |
parents | dba522b4c31d |
children |
line wrap: on
line source
from datetime import datetime class Link(object): def __init__(self, username, url, title): self.username = username self.url = url self.title = title self.time = datetime.utcnow() self.id = hex(hash(tuple([username, url, title, self.time])))[2:] self.comments = [] def __repr__(self): return '<%s %r>' % (type(self).__name__, self.title) def add_comment(self, username, content): comment = Comment(username, content) self.comments.append(comment) return comment class Comment(object): def __init__(self, username, content): self.username = username self.content = content self.time = datetime.utcnow() def __repr__(self): return '<%s by %r>' % (type(self).__name__, self.username)