annotate examples/tutorial/geddit/model.py @ 830:a55e4d51b8ff experimental-inline

inline branch: synced with trunk@1038.
author cmlenz
date Fri, 13 Mar 2009 20:04:26 +0000
parents 9755836bb396
children
rev   line source
820
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
1 from datetime import datetime
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
2
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
3
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
4 class Link(object):
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
5
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
6 def __init__(self, username, url, title):
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
7 self.username = username
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
8 self.url = url
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
9 self.title = title
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
10 self.time = datetime.utcnow()
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
11 self.id = hex(hash(tuple([username, url, title, self.time])))[2:]
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
12 self.comments = []
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
13
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
14 def __repr__(self):
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
15 return '<%s %r>' % (type(self).__name__, self.title)
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
16
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
17 def add_comment(self, username, content):
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
18 comment = Comment(username, content)
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
19 self.comments.append(comment)
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
20 return comment
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
21
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
22
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
23 class Comment(object):
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
24
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
25 def __init__(self, username, content):
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
26 self.username = username
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
27 self.content = content
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
28 self.time = datetime.utcnow()
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
29
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
30 def __repr__(self):
9755836bb396 Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
diff changeset
31 return '<%s by %r>' % (type(self).__name__, self.username)
Copyright (C) 2012-2017 Edgewall Software