annotate examples/tutorial/geddit/model.py @ 1027:34cf6abaa6e7 trunk

Add Python 3.4 to tox environment list.
author hodgestar
date Wed, 19 Mar 2014 13:36:27 +0000
parents abad7c2ebe15
children
rev   line source
611
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
1 from datetime import datetime
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
2
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
3
619
756e7418e10c GenshiTutorial: various updates to sync with wiki page.
cmlenz
parents: 618
diff changeset
4 class Link(object):
611
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
5
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
6 def __init__(self, username, url, title):
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
7 self.username = username
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
8 self.url = url
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
9 self.title = title
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
10 self.time = datetime.utcnow()
619
756e7418e10c 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
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
12 self.comments = []
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
13
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
14 def __repr__(self):
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
15 return '<%s %r>' % (type(self).__name__, self.title)
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
16
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
17 def add_comment(self, username, content):
625
abad7c2ebe15 GenshiTutorial: implemented AJAX commenting.
cmlenz
parents: 619
diff changeset
18 comment = Comment(username, content)
abad7c2ebe15 GenshiTutorial: implemented AJAX commenting.
cmlenz
parents: 619
diff changeset
19 self.comments.append(comment)
abad7c2ebe15 GenshiTutorial: implemented AJAX commenting.
cmlenz
parents: 619
diff changeset
20 return comment
611
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
21
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
22
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
23 class Comment(object):
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
24
618
b6706f9346ac Simplify the tutorial project: comments are now flat, not hierarchical.
cmlenz
parents: 611
diff changeset
25 def __init__(self, username, content):
611
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
26 self.username = username
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
27 self.content = content
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
28 self.time = datetime.utcnow()
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
29
236c351928a2 Add current code for GenshiTutorial to the `examples` directory.
cmlenz
parents:
diff changeset
30 def __repr__(self):
625
abad7c2ebe15 GenshiTutorial: implemented AJAX commenting.
cmlenz
parents: 619
diff changeset
31 return '<%s by %r>' % (type(self).__name__, self.username)
Copyright (C) 2012-2017 Edgewall Software