Design tips requested for OOP forum system (using pickle)

Christian Tanzer tanzer at swing.co.at
Fri Nov 30 01:55:19 EST 2001


cs1spw at bath.ac.uk (Simon Willison) wrote:

> User - an object representing a single forum user account
> Forum - an object representing a forum (e.g "General Chat" or "Site
> Suggestions")
> Thread - an object representing a thread
> Post - an object representing an actual post
(snip)
> One thing I haven't quite figured out yet is how to relate posts to
> the user object for the user that posted that post. Should I look at
> storing some kind of user ID and then searching through my user
> objects for an object with that ID stored within it every time I
> display a post? That sounds horribly inefficient - performance is not
> a major concern for this software as it's intended for personal small
> scale use but I don't want to write something that's virtually
> unusable due to performance problems...

How about:

    - Post_by_User.post(u) --> returns list of all (post, user) links
      for user `u`

    - Post_by_User.user(p) --> returns list of all (post, user) links
      for post `p`

    - Post_by_User.link(p, u) --> return (post, user) link for `p` and
      `u` or None

    - Post_by_User.add(p, u) <-- adds a new link for `p` and `u`

Of course, the links could also contain additional attributes
relevant to a specific (post, user) combination.

If you use dictionaries, performance shouldn't be an issue.

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92





More information about the Python-list mailing list