Congratulations! You have just finished your first little Zope 3 application, which is quiet a bit more than what would minimally be required as you will see in a moment. It is time now to harvest the fruits of your hard work. Start your Zope 3 server now, best using makerun from the Zope 3 root. If you get complains about the Python version being used, edit the Makefile and enter the correct path to Python’s executable. Other errors that might occur are due to typos or mis-configurations. The ZCML interpreter will give you the line and column number of the failing directive in Emacs-friendly format. Try to start Zope 3 again and again until you have fixed all the errors and Zope 3 starts up ending with this output:

恭喜恭喜! 您已经完成Zope3 的一个小应用, 尽管小但你仍需要花些时间在这上面。现在是你付出辛勤劳动后收获果实的时候。现在请启动你的Zope3服务器,最好从Zope3根目录运行makerun.当你使用时如果由于Python版本而引起任何怨言,请编辑Makefile并且进入Python正确的路径执行。其它错误有可能是由错别字或错误的配置而引起的。ZCML翻译器将以Emacs-friendly格式显示错误指令所在的行号和列号。请试着反复启动Zope3直到你已经修正了所有的错误并且Zope3能正确运行你的成果。

1


2 2003-12-12T23:14:58 INFO PublisherHTTPServer zope.server.http (HTTP) started. 3 Hostname: localhost 4 Port: 8080 5


6 2003-12-12T23:14:58 INFO PublisherFTPServer zope.server.ftp started. 7 Hostname: localhost 8 Port: 8021 9


10 2003-12-12T23:14:58 INFO root Startup time: 11.259 sec real, 5.150 sec CPU

Note that you also get some internationalization warnings, which you can safely ignore for now.

注意你可能会得到一些国际化警告,暂时你可以安全地忽略它

Once the server is up and running, go to your favorite browser and display the following URL:

一旦服务器已经运行,请使用你的浏览器运行如下地址: http://localhost:8080/@@contents.html

At this point an authentication box should pop up and ask you for your username and password - users are listed in the principals.zcml. If you have not added any special user, use “gandalf” as the login name and “123” as password. After the authentication is complete you should be taken to the Zope 3 Web user interface. Under Add: you can now see a new entry “Message Board”.

这时将会弹出一个要你输入用户名和密码的认证框,用户将在principals.zcml文件中列出。如果您未增加任何特别用户, 请使用gandalf作为登陆名、123作为密码。认证结束后你将进入到Zope3的web用户界面。

现在你可以看到“Message Board”。

Feel free to add and edit a message board object.

现在你可以自由增加和编辑message board对象。

Once you created a message board, you can click on it and enter it. You will now notice that you are only allowed to add “Message” objects here. The choice is limited due to the conditions we specified in the interfaces. The default view will be the “Edit” form that allows you to change the description of the board. The second view is the “Contents” with which you can manage the messages of the message board.

一旦你创建了一个message board,您能点击它和进入它。您现在注意, 您只被允许在这儿增加Message对象。之所以选择有限是由于我们在接口中的指定了条件。缺省视图是允许你改变board 描述的Edit表单。第二个视图是允许你管理message board中的message的Contents。

Add a “Message” now. Once you added a message, it will appear in the “Contents” view. You can now click on the message. This will allow you to modify the data about the message and add new messages (replies) to it. With the code we wrote so far, you are now able to create a complete message board tree and access it via the Web UI.

现在增加一个Message。 一旦您增加了一则消息, 它将出现在Contents视图中。 您能单击消息。这将允许您修改消息数据和增加新消息(回复)。 以上代码我们就写到目前为止, 您现在能创建一棵完整的留言簿树并且通过Web界面来访问它。

Note that you still might get errors, in which case you need to fix them. Most often you have security problems, which narrows the range of possible issues tremendously. Unfortunately, NotFoundError is usually converted to ForbiddenAttributeError, so be careful, if you see this problem.

在您需要修正他们的情况下,注意您仍然会得到错误。经常会是安全问题,这也许能使查找的范围变得小些。不幸地是NotFoundError 通常被转换成ForbiddenAttributeError, 因此如果您看到这种问题后请小心行事。

Another common trap is that standard error screens do not show the traceback. However, for these situations the Debug skin comes in handy - instead of http://localhost:8080/@@contents.html use http://localhost:8080/++skin++Debug/@@contents.html and the traceback will be shown.

其它缺陷是标准的错误界面不显示traceback 。 然而,为了让皮肤调试变得更为得心应手,可以用http://localhost:8080/++skin++Debug/@@contents.html代替http://localhost:8080/@@contents.html,代替后HTML 和traceback 将被显示。

Note: If you make data-structural changes in your package, it might become necessary to delete old instances of the objects/components. Sometimes even this is not enough, so that you have to either delete the parent Folder or best delete the Data.fs (ZODB) file. There are ways to upgrade gracefully to new versions of objects, but during development the listed methods are simpler and faster.

注: 如果您在你的包内做了数据结构方面的变动, 在objects/components中删除旧的实例变得很有必要,有时光删除实例还不够,以至于你必须删除父文件夹或者最好是删除数据库文件Data.fs (ZODB)。这些都是更新一个新版本对象可以采取的方法,但是在开发期间列出所有的方法是最简单和快速的。

The code is available in the Zope SVN under http://svn.zope.org/book/trunk/messageboard/step01.

下面地址提供了该示例的代码:

http://svn.zope.org/book/trunk/messageboard/step01.


CategoryCookbook