Implementing new Content objects in Zope 3 is important to zope3http://www.aliyun.com/zixun/aggregation/7155.html "> developers." To make the explanation more operational, this chapter will use a guest book example to help you understand. In the following chapter, we will list the major steps required to implement and register a new content component in Zope3.
This chapter will be a starting point for us to develop a messageboard type. Before the task starts, we think you've installed Zope 3, and you already have Python programming skills, and of course, the more important thing is that you're happy to spend some time learning about the Zope framework.
Step I: Preparing for work
Before you start, you should have installed Zope 3, created the Principal.zcml file, and started Zope successfully. Did you do it? OK, then, let's get started.
Relative to Zope2, Zope3 does not require you to add a package to the specified directory, and you can choose where you think it is convenient to add it. The best place to put it is in the ZOPE3/SRC (ZOPE3 is your Zope3 installation directory), because in that case, we don't have to worry about confusing with pythonpath. In addition, in order to make the contents of the book appear more neat and clear, we put all the program code into a package called books. In Unix, create the book directory with the following command:
1 mkdir Zope3/src/book
Put an empty <u>init</u>.py file in a new directory, and in Unix you can do this by using the following command:
1 echo "# make it a Python package" >> zope3/src/book/<u>init</u>.py
However, you can certainly use a text editor to create the file, but you need to be sure that the Python program code in the file is correct. Typically, a file should contain at least a few spaces, because empty files often confuse some archive files. Now we are creating another messageboard package in the book in a similar way (don't forget to create the <u>init</u>.py file). From now on, all the work we need to do below is done in the messageboard package, which is located in Zope3/src/book/messageboard.
Note: You can download the source code for each step we have made: Http://svn.zope.org/book/trunk/messageboard which contains the license, and in order to reduce the input, we have omitted the license-related information in the entire source program. This does not mean that the source program is not copyrighted, and in fact, copyright still exists in these source files.
Step II: Preliminary design
As we mentioned earlier, our original intention is to develop a web-based guest book application, which does not require a very beautiful interface, but a very complete function. The specific design is that the root object messageboard can hold records or message objects from different users. In addition, because we want users to respond to different messages, we need to allow messages to contain replies.
That means 11545.html "> We have two container based components: Messageboard only contains messages that can be added to any folder or containers that want to contain messages. Messageboard should have a description of the topic discussion (description). On the other hand, Messages (message) is only included in the guest book or other messages. Each message will have a title and body.
The setting should contain what we need to make this available object. Later on, we will combine many other metadata related to these components and integrate them better into zope3, and will also add related accessibility features.