[workshop] rantelope day 005: comment system and next steps

Michal Wallace workshop@cornerhost.com
Sat, 28 Sep 2002 16:15:12 -0400 (Eastern Daylight Time)


rantelope: day 005
-----------------------------
comment system and next steps
-----------------------------

Today I added comments, rounding out the core feature
set, and began thinking about how rantelope *the application*
will eventually work.

As usual, the code and demo are up at:

    http://www.rantelope.com/

You also can now get the code via anonymous CVS:

 cvs -d:pserver:anonymous@cvs.sabren.com:/cvs/sixthdev co MODULE

Where MODULE is python module name:
  (rantelope, ransacker, sixthday, storage, arlo, etc.)


==[ today's objective ]==

The last feature to add was a comment system. It's
simple, so I'm just going to jump into the 
implementation here:

==[ implementation ]==

I wanted to show a page with a story, list all the
comments underneath it, and then show a form for 
people to add their own comments.

Step by step, it went like this:

1. Create a Comment class and corresponding table:

     ## python ##
     class Comment(Strongbox):
         ID = attr(long)
         storyID = attr(long)
         name = attr(str)
         mail = attr(str)
         link = attr(str)
         note = attr(str)

     -- MySQL --
     CREATE TABLE rnt_comment (
         ID int not null auto_increment primary key,
         storyID int not null,
         name varchar(50),
         mail varchar(50),
         link varchar(255),
         note text
     );


2. Define the relationship between Story and Comments:

    class Story(Strongbox):
        ...
        comments = linkset(Comment)

    ...

    dbmap = {
        ...
        Story.__attrs__["comments"]: (Comment, "storyID"),
        Comment: "rnt_comment"}


3. Add actions to RantelApp for showing stories and 
   saving comments:

    def show_story(self):
        self.generic_show(Story, "sho_story")

    def save_comment(self):
        cmt = self.generic_save(Comment)
        self.redirect(action='show&what=story&ID='
                            + str(cmt.storyID))

4. Create template called sho_story.zb.

   This is simple, but long. See:
   http://cvs.sabren.com/sixthdev/cvsweb.cgi/rantelope/sho_story.zb?rev=1.1


Pretty simple, huh? 

Of course, finding the comments page is kind of tricky, and it's not
hooked up to the templates, and the search engine STILL isn't hooked
up, and the whole application is just plain ugly.  Which brings me to
my next point...

==[ the future ]==

Right now, rantelope is just a bundle of features. It leaves a lot of
questions open. Is rantelope a tool users install themselves to manage
their sites? Or should it be more like the blogger server, where
people log in and publish their changes across the net?

How should templates be shared between channels, stories, and
comments?

Do we need to implement a login feature, or can we delegate that to
the webserver? If we do have users, how about multiple users, with
different permissions based on the channel?

When, exactly do channels get published? What about archives? How
should the navigation be set up?

What about email? Can you email a post to a blog? Can the blog notify
subscribers of new stories?

What about importing RSS? Or templates from other tools? There's no
reason our various objects couldn't be stored directly in RSS files,
bypassing MySQL completely.

In other words, the future is wide open. A single program 
can't do <i>everything</i>, and that's where design comes in.

I believe software design can and should be an interative process.
A week ago, I wrote out which features would have to be there to 
build a content management system. Then I built each one in turn.
The result seems like an ugly mess, but it more or less works.

Actually, you might say that this week, we've created 
some technology for content management. Now we want to 
build an *application* of that technology, that people 
can actually use.

So the next step is to figure out exactly how that application
should interact with the world. I'll be working that out over
the next two weeks. If you have suggestions, comments, feature
requests, or questions, feel free to email me or post to the
list. 

Sincerely,

Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: michal@sabren.com
hosting: http://www.cornerhost.com/
my site: http://www.sabren.net/
--------------------------------------