view examples/tutorial/geddit/model.py @ 743:7fa3af78556f experimental-soc2008

Path.test() function reimplementation and few Changed path.py tests to play well with new understanding of few things In test suite one test fails, don't know why yet
author mkurczych
date Sat, 07 Jun 2008 19:22:31 +0000
parents abad7c2ebe15
children
line wrap: on
line source
from datetime import datetime


class Link(object):

    def __init__(self, username, url, title):
        self.username = username
        self.url = url
        self.title = title
        self.time = datetime.utcnow()
        self.id = hex(hash(tuple([username, url, title, self.time])))[2:]
        self.comments = []

    def __repr__(self):
        return '<%s %r>' % (type(self).__name__, self.title)

    def add_comment(self, username, content):
        comment = Comment(username, content)
        self.comments.append(comment)
        return comment


class Comment(object):

    def __init__(self, username, content):
        self.username = username
        self.content = content
        self.time = datetime.utcnow()

    def __repr__(self):
        return '<%s by %r>' % (type(self).__name__, self.username)
Copyright (C) 2012-2017 Edgewall Software