While some people immediately understand the usefulness of Zope, others don't understand how to apply their skills. In this article, Peyton McCullough explains how to apply the skills to create a simple forum.
Let's now create a list of topics in a given category. As you saw in the previous script, we need to create a file named cat. Go ahead and create a Zope Page Template named cat. Insert the following text into it:
Again, we use the macro to make our page's layout match the layouts of the other files. Feel free to edit the macro and experiment with different styles.
We use a conditional expression to determine whether the category contains any topics. If it does, we call the file getTopics in the current context. If the folder contains no objects, we display a message which explains that there are no topics available. Finally, we create a form that allows us to add new topics. The form sends its data to a file called newTopic.
Create a Script ( Python ) object with the name of getTopics. This script will create a list of topics and format them. Insert the following script into it:
Although the code may look complicated, its function is pretty simple. First, it counts the number of topics currently in the category. For simplicity's sake, the topic folder Ids will just be numbers. The first topic will be 1, the second 2, the third 3 and so on.
We then create a folder for the topic with the appropriate title. Next, we add an author property, and, finally, we create the first reply and add its author property.