|
Revision 28, 0.8 kB
(checked in by davbo, 20 months ago)
|
|
geddit stuff
|
| Line | |
|---|
| 1 | |
|---|
| 2 | from datetime import datetime |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | class Link(object): |
|---|
| 6 | |
|---|
| 7 | def __init__(self, username, url, title): |
|---|
| 8 | self.username = username |
|---|
| 9 | self.url = url |
|---|
| 10 | self.title = title |
|---|
| 11 | self.time = datetime.utcnow() |
|---|
| 12 | self.id = hex(hash(tuple([username, url, title, self.time])))[2:] |
|---|
| 13 | self.comments = [] |
|---|
| 14 | |
|---|
| 15 | def __repr__(self): |
|---|
| 16 | return '<%s %r>' % (type(self).__name__, self.title) |
|---|
| 17 | |
|---|
| 18 | def add_comment(self, username, content): |
|---|
| 19 | comment = Comment(username, content) |
|---|
| 20 | self.comments.append(comment) |
|---|
| 21 | return comment |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | class Comment(object): |
|---|
| 25 | |
|---|
| 26 | def __init__(self, username, content): |
|---|
| 27 | self.username = username |
|---|
| 28 | self.content = content |
|---|
| 29 | self.time = datetime.utcnow() |
|---|
| 30 | |
|---|
| 31 | def __repr__(self): |
|---|
| 32 | return '<%s by %r>' % (type(self).__name__, self.username) |
|---|