Edgewall Software

source: trunk/examples/tutorial/geddit/model.py

Last change on this file was 741, checked in by cmlenz, 16 years ago

GenshiTutorial: implemented AJAX commenting.

  • Property svn:eol-style set to native
File size: 823 bytes
Line 
1from datetime import datetime
2
3
4class Link(object):
5
6    def __init__(self, username, url, title):
7        self.username = username
8        self.url = url
9        self.title = title
10        self.time = datetime.utcnow()
11        self.id = hex(hash(tuple([username, url, title, self.time])))[2:]
12        self.comments = []
13
14    def __repr__(self):
15        return '<%s %r>' % (type(self).__name__, self.title)
16
17    def add_comment(self, username, content):
18        comment = Comment(username, content)
19        self.comments.append(comment)
20        return comment
21
22
23class Comment(object):
24
25    def __init__(self, username, content):
26        self.username = username
27        self.content = content
28        self.time = datetime.utcnow()
29
30    def __repr__(self):
31        return '<%s by %r>' % (type(self).__name__, self.username)
Note: See TracBrowser for help on using the repository browser.