Mercurial > genshi > genshi-test
annotate examples/tutorial/geddit/model.py @ 912:46db99909472 experimental-py3k
py3k branch: add 2to3 build infrastructure to setup.py (this pulls the tests into the source distribution so that tests can be run after building with 2to3)
author | hodgestar |
---|---|
date | Sun, 24 Oct 2010 21:09:36 +0000 |
parents | dba522b4c31d |
children |
rev | line source |
---|---|
611
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
1 from datetime import datetime |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
2 |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
3 |
619
71d3edd302ae
GenshiTutorial: various updates to sync with wiki page.
cmlenz
parents:
618
diff
changeset
|
4 class Link(object): |
611
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
5 |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
6 def __init__(self, username, url, title): |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
7 self.username = username |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
8 self.url = url |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
9 self.title = title |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
10 self.time = datetime.utcnow() |
619
71d3edd302ae
GenshiTutorial: various updates to sync with wiki page.
cmlenz
parents:
618
diff
changeset
|
11 self.id = hex(hash(tuple([username, url, title, self.time])))[2:] |
611
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
12 self.comments = [] |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
13 |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
14 def __repr__(self): |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
15 return '<%s %r>' % (type(self).__name__, self.title) |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
16 |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
17 def add_comment(self, username, content): |
625 | 18 comment = Comment(username, content) |
19 self.comments.append(comment) | |
20 return comment | |
611
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
21 |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
22 |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
23 class Comment(object): |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
24 |
618
5a2059ce1f0b
Simplify the tutorial project: comments are now flat, not hierarchical.
cmlenz
parents:
611
diff
changeset
|
25 def __init__(self, username, content): |
611
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
26 self.username = username |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
27 self.content = content |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
28 self.time = datetime.utcnow() |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
29 |
16b1be35c265
Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff
changeset
|
30 def __repr__(self): |
625 | 31 return '<%s by %r>' % (type(self).__name__, self.username) |