Log in |
Create folderish classesThis how-to describes making a folderish class. There are several how-to's already on how to make simple objects such as the Boring Product (1) and the Minimal Product(2). One useful object though that can create a very powerful product is the Folderish object and this how-to covers the ins and outs of creating a simple Folderish based product, Simple Posting (3). Simple Posting is a class to create the kind of postings that people put on articles such as on slashdot.org (but hopefully more useful comments). The basic structure is that a user can post a comment on a article. They can post a comment about a comment or on the original article. And so on, which can simply be represented by a simple tree of folders from the originating article down.
Why a folderish object?Why not? A folderish object has the ability to hold objects, a non-folderish object hasn't. A non-folderish object can render dtml from "data", where as this can be mind-bendingly annoying for a folderish object. This can turn into a bit of a science project, avoid it.
The extra overhead of folderish object is so minimal that I have found unless your object renders dtml from user input (eg: DTML Document), use a folderish object. I have one site that scales very nicely with about 10,000 nested folderish objects. How do I make one?Very similar to a normal object... 1. create a folder and put in it __init__.py __init__.py ... 2. start off your class Posting.py ... header stuff
References |