个人工具

Zope3宝典/安装Zope3

来自Ubuntu中文

跳转至: 导航, 搜索

Chapter 1: Installing Zope 3(安装 Zope 3)


原文出处:The Zope 3 Developers Book - An Introduction for Python Programmers

原文作者:StephanRichter, zope.org

授权许可:创作共用协议

翻译人员:

  • 马 剑 <honeyday.mj@gmail.com>

校对人员:Leal, FireHare

适用版本:Zope 3

文章状态:校正阶段




Difficulty
难度

Newcomer
新手

Skill
技能

  • You should know how to use the command line of your operating system. (For Windows releases, the Installer is provided.)
    你应该知道如何使用你的操作系统的命令行(对于windows发布版,已经提供了安装程序。)
  • You need to know how to successfully install the latest version of Python on your system.
    你需要知道如何在你的系统上成功的安装最新的Python。

Problem/Task
问题/任务

Before you can develop anything for Zope 3, you should, of course, install it.
在我们能在Zope3上面开发任何东西之前,我们当然需要先安装它。

Solution
解决方案

1.1 Zope 3 Installation Requirements(Zope 3 的安装需求)

Zope 3 usually requires the latest stable Python version. For the Zope X3 3.0.0 release, this is Python 2.3.4 or better. Note that you should always use the latest bug-fix release. Zope 3 does not require you to install or activate any special packages; the stock Python is fine. This has the great advantage that you can use a pre-packaged Python distribution (for example RPM, deb, Windows Installer) for your favorite operating system.
Zope3通常需要最新的稳定版的Python。对于Zope X3 3.3.0发布版来说,使用Python 2.3.4或者更高的。需要注意的是,你应该总是使用最新的修正错误的发布版。Zope3并不需要你安装或激活任何特殊的包;使用最普通的Python即可。这最大的好处就是你可以在你喜欢的操作系统上使用预先打包的Python发行版。(例如:PRM,deb,windows安装程序)

Note: While distutils is part of the standard Python distribution, packagers often treat it as a separate installation package. In order to install Zope 3, your Python must have distutils installed as well.
注意: 当 distutils 成为 Python 标准发布的一部分之后,打包人员经常将其单独作为一个安装包。为了安装 Zope 3,你的 Python 同样也必须安装 distutils。

The only catch is that Zope 3’s C modules must be compiled with the same C compiler as Python. For example, if you install the standard Python distribution on Windows, which is compiled with Visual C++ 7, you cannot compile Zope 3’s modules with Cygwin. However, this problem is not as bad as it seems. The Zope 3 binary distributions are always compiled with the same compiler as the standard Python distribution for the operating system. Furthermore, if you want to compile everything yourself, you are likely to use only one compiler anyway.
唯一需要注意的是编译Zope3的C模块的时候必须使用与编译Python时使用的编译器一样。例如,你在Windows上安装了由Visual C++ 7编译的Python标准版,就不能使用Cygwin来编译你的Zope 3的模块。然而,问题并不会像看上去那么严重。Zope3的二进制分发版总是使用与Python标准版一样的编译器编译的。另一方面,如果你想自己编译所有的内容,那么一定要使用一个编译器。

On Unix/Linux your best bet is gcc. All Zope 3 developers are using gcc, so it will always be supported. Furthermore, all Linux Python distribution packages are compiled using gcc. In Windows, the standard Python distribution is compiled using Visual C++ 7, as mentioned previously. Therefore the Zope 3 binary Windows release is also compiled with that compiler. However, people have also successfully used gcc by using Cygwin, which comes with Python. Finally, you can run Zope 3 on MacOS X as well. All you need are gcc and the make program. With these, both Python and Zope 3 compile just fine.
在Unix/Linux上最好的选择是gcc。所有的Zope3开发者都使用gcc,所以它总是被支持的。在windows上,像上面提到的那样,标准 Python分发版使用Visual C++ 7编译的。因此,Zope3的windows二进制发布版也是使用那个编译器编译的。不管怎么说,人们已经成功得利用Cygwin(和Python一起发布的)来使用gcc了。最后,你还能在MacOS X上运行Zope3。

Python is available at the Python Web site (www.python.org).
Python 可以在 Python 的网站上找到(www.python.org)

1.2 Installing Zope from SVN(从SVN安装 Zope)

In order to check out Zope 3 from SVN, you need to have a SVN client installed on your system. If you do not have a SVN account, you can use the anonymous user to check out a sandbox:
为了从SVN中检出Zope3,你需要有一个SVN客户端安装在你的系统上。如果你没有SVN帐户,用户你可以使用佚名的用户来得到一个沙箱检出:

1  svn co svn://svn.zope.org/repos/main/Zope3/trunk Zope3

After the checkout is complete, you enter the Zope 3 directory:
检出完成后,进入Zope3的目录:

1  cd Zope3

From there you run make (so you need to have make installed, and it should be available for all mentioned environments). If your Python executable is not called python2.3 and/or your Python binary is not in the path, you need to edit the first line of the Makefile file to contain the correct path to the Python binary. Then you just run make, which builds/compiles Zope 3:
从那里运行make(你需要有安装过make,它应该所有提到的环境中有效)。如果你的Python可执行文件不是叫Python2.3和/或者你的 Python二进制文件不在PATH中,编辑Makefile的第一行,改正Python二进制文件的路径。现在运行make,它将建立/编译 Zope3:

1  make

Next you copy sampleprincipals.zcml to principals.zcml and add a user with manager rights, as follows:
将 sample_principals.zcml 的内容复制到principals.zcml中,并增加一个有管理员权限的用户,如下:

1  <principal
2      id="zope.userid" title="User Name Title"
3      login="username" password="passwd" />
4  
5  <grant role="zope.Manager" principal="zope.userid" />

In the preceding code block, note the following:
在前面的代码块中,注意到下列现象:

  • Line 2: Notice that you do not need zope. as part of your principal ID, but the ID must contain at least one dot ( .), because that signals a valid ID.
    第 2 行:注意你没有必要将"zope."作为你的principal id的一部分,但是principal id必须包含至少一个点("."),因为这是有效id的标志。
  • Line 3: The login and password strings can be any random value, but they must be correctly encoded for XML.
    登录(login)和口令(password)字符串可以是任何的任意值,但是必须可以正确编码为XML。
  • Line 5: If you do not use the default security policy, you might not be able to use this zope:grant directive because it might not support roles. However, if you use the plain Zope 3 checkout, roles are available by default.
    如果你没有使用默认的安全策略,你可能不能使用zope:grant指令,因为它可能不支持角色。然而你使用普通的Zope3检出,那么作为默认角色是生效的。

During development, you often do not want to worry about security. In such a case you can simply give anybody the Manager role:
此外,在开发的过程中你经常不需要担心安全问题。这样的话你可以将管理员角色分配给任何人:

1  <grant role="zope.Manager" principal="zope.anybody" />

The fundamental application server configuration can be found in zope.conf. If zope.conf is not available, zope.conf.in is used instead. In this file you can define the types and ports of the servers you would like to activate, setup the ZODB storage type and specify logging options. The configuration file is very well documented, and making the desired changes should be easy.
原始的应用服务器配置在zope.conf中。如果zope .conf不存在,那么将使用zope.conf.in来替代。在这个文件中你可以定义你想激活的服务器的类型和端口,设置ZODB存储器类型和指定日志选项。配置文件有很好的文档并且它应该很易于修改。

Now you are ready to start Zope 3 for the first time:
现在我们准备第一次启动Zope3:

1  ./bin/runzope

The following output text should appear:
以下的输出本文将呈现:

1  ------
2  2003-06-02T20:09:13 INFO PublisherHTTPServer zope.server.http (HTTP) started.
3          Hostname: localhost
4          Port: 8080
5  ------
6  2003-06-02T20:09:13 INFO PublisherFTPServer zope.server.ftp started.
7          Hostname: localhost
8          Port: 8021
9  ------
10  2003-06-02T20:09:13 INFO root Startup time: 5.447 sec real, 5.190 sec CPU

After Zope comes up, you can test the servers by typing the following URL in your browser: http://localhost:8080/. You can test FTP by using ftp://username@localhost:8021/. Even WebDAV is available using webdav://localhost:8080/ in Konqueror or your favorite WebDAV client.
当Zope启动后,你现在可以通过在你的浏览器中键入以下的URL来测试:http://localhost:8080/ 。测试FTP使用 ftp://username@localhost:8021/ 。并且甚至可以在Konqueror里使用 webdav://localhost:8080/ 来测试WebDAV。

An XML-RPC server is also built in to Zope by default, but most objects do not support any XML-RPC methods, so you cannot test it right away. Chapter “??” provides detailed instructions on how to use the XML-RPC server.
一个XML-RPC服务器也默认内建在里面了,但是大多数的对象并不支持任何的XML-RPC方法,因此你还不能立刻测试它。参见"经由XML-RPC的可用性"章节来获得详细的指引,关于如何使用XML-RPC服务器。

1.3 Installing the Source Distribution(安装源代码分发版)

following sections describe how to use the source TAR ball to compile and install a Zope 3 distribution.
接下来的几个小节描述了如何使用源文件的 TAR 包进行编译,并对 Zope 3 的发行版进行安装

1.3.1 Unpacking the Package

The latest release of Zope 3 can be found at http://www.zope.org/Products/ZopeX3. First, you need to download the latest Zope 3 release by clicking the file that is available for all platforms, i.e. ZopeX3-VERSION.tgz. You can use tar or WinZip to extract the archive, like this:
Zope 3 最新的发行版可以在 http://www.Zope.org/Products/ZopeX3 找到。首先,通过点击对应所有地平台的文件来下载最新的 Zope3 发行版,如 ZopeX3-VERSION.tgz。使用 tar 或者 WinZip 来解压档案,如下所示:

1  tar xzf ZopeX3-3.0.0.tgz

1.3.2 Building Zope(构建 Zope)

For Zope 3 releases, distributation makers provided the well-known configure/ make procedure. So you can start the configuration process by using the following after you have entered the newly created directory:
对于这个发行版我们提供了著名的"configure"/"make"程序。所以在你进入新建的目录后,你可以通过实用下面的语句启动配置过程:

1  ./configure

If you want to place the binaries of the distribution somewhere other than /usr/local/ZopeX3-VERSION, you can specify the -prefix option as usual. Also, if you have Python installed at a non-standard location, you can specify the Python executable by using -with-python. A full configuration statement could look like this:
如果你希望将二进制文件放到除了/usr/local/ZopeX3-VERSION以外的地方,你可以象往常一样指定--prefix选项。同样,如果你的Python安装在非标准的位置,你可以使用 -with-python 来指定Python可执行文件。一个完整的配置语句可以是:

1  ./configure --prefix=/opt/Zope3 --with-python=/opt/puython2.3/bin/python2.3

The following output is immediately returned:
立即返回的输出是:

1  Configuring Zope X3 installation
2  
3  Using Python interpreter at /opt/puython2.3/bin/python2.3

Now that the source has been configured, you can build it by using make. After you enter the make command, the following line is returned:
现在源已经配置好了,我们可以用make来构建它了。在你打入make命令之后,将返回下面一行提示:

1  /opt/python2.3/bin/python2.3 install.py -q build

The hard drive is busy for several minutes, compiling the source. When the command line returns, you can run the tests by using the following:
返回并且硬盘驱动器将忙碌几分钟来编译源代码。当命令行返回后,你可以使用下面的命令运行测试:

1  make check

Here, both the unit and functional tests are executed. For each executed test, you have one dot on the screen. The check takes between 5 and 10 minutes depending on the speed and free cycles on your computer. The final output should look as follows:
在这里,单元测试和功能测试将被执行。对于每个执行的测试你将看到屏幕上出现一个"点"。检测将持续5-10分钟,这依赖你的电脑的速度和硬盘的剩余空间(free cycles:空闲的柱面)。 最终的输出将如下所示:

1  Python2.3 install.py -q build
2  Python2.3 test.py -v
3  Running UNIT tests at level 1
4  Running UNIT tests from /path/to/ZopeX3-VERSION/build/lib.linux-i686-2.3
5  [some 4000+ dots]
6  ----------------------------------------------------------------------
7  Ran 3896 tests in 696.647s
8  
9  OK

The exact number of tests run depends on the version of Zope, the operating system, and the host platform. If the last line displays OK, you know that all tests passed. After you have verified the check, you can install the distribution as follows:
测试的确切数量将依赖于Zope的版本,操作系统和主机平台。如果最后一行显示"OK ",你就知道所有的测试都通过了。当校验过检测后,你可以使用make install来安装这个分发版了。

1  make install

Note: You have to have the correct permissions to create the installation directory and copy the files into it. Thus, it might be useful to become root to execute the command.
注意:你必须要有一个正确的权限去创建安装目录并将文件拷入其中。因此,成为根用户去执行命令可能会有用。

1.3.3 Creating a Zope Instance(创建一个Zope实例)

When the installation is complete, Zope is available in the directory you specified in -prefix or under /usr/local/ZopeX3-VERSION. However, Zope will not yet run, because you have not created an instance yet. You use instances when you want to host several Zope-based sites, using the same base software configuration.
当安装完成后,Zope将存在在你在--prefix指定的目录中或者在/usr/local/ZopeX3-VERSION下面。然而,Zope还不能运行,因为你还没有创建创建一个实例。实例是用于下面这种情况的:当想利用相同的基本软件配置来做多个基于Zope的站点时。

Creating a new instance is easy. You enter the Zope 3 installation directory and enter the following command:
创建一个新实例是容易的。 进入Zope3目录并输入以下命令:

1  /bin/mkzopeinstance -u username:password -d path/to/instance

This creates a Zope 3 instance in path/to/instance. A user who has the login username and password password is created for you, and the zope.manager role is assigned to it. All the configuration for the created instance are available in the path/to/instance/etc directory. You need to review all the information in there to ensure that it fits your needs.
这将在path/to/instance 路径下面创建一个Zope实例。一个有登录"用户名"和登录"口令"的用户将被创建,同时将"zope.manager"角色分配给它。刚创建的实例的所有配置在path/to/instance/etc目录下。请检查在那里面的所有信息以保证它适合你的需要。

1.3.4 Running Zope

You execute Zope by calling

1  ./bin/runzope

from the instance directory. The startup output will be equal to that of the source Zope SVN installation.
在实例目录中通过调用

1  ./bin/runzope

来执行Zope。启动输出的内容将和从SVN安装的Zope一模一样。

You are all done now! When the server is up and running, you can test it via you favorite browser, as described earlier in this chapter.
所有的事情都完成了。当服务器启动并运行后,你可以使用你喜爱的浏览器来测试它,就像之前提到的那样。

1.4 Installing the Source Distribution in Windows Without Using make(在Windows上采用非MAKE方式安装源代码分发版)

Installing the source distribution on Windows is possible even without make. However, you need a supported C compiler to build the package. If you do not have a C compiler or Cygwin installed, you can use the Windows Installer to install Zope 3. (See the next section for more details.)
在Windows上也可以不使用make来安装源代码分发版。 然而,你需要一个支持C的编译器以来建立包。 如果你没有安装C编译器或者Cygwin,那么请使用Windows安装程序来安装Zope3。(更多详情请看下一节)

Before installing Zope 3, you need to install Python 2.3.4 or higher. On Windows NT/2000/XP the extension .py is automatically associated with the Python executable, so you do not need to specify the Python executable when running a script.
在安装Zope3之前,你需要安装Python 2.3.4或者更高的版本。 在Windows NT/2000/XP上.py扩展名的文件自动的关联到Python可执行文件,因此运行一个脚本时你不需要指定Python可执行文件。

After you unpack the distribution, you enter the directory. You build the software by using this:
解压分发版之后,进入该目录。 用下面的语句建立:

1  install.py -q build

When the build process is complete, you can run the tests with this:
当建立过程完成后,你可以用下面的命令运行测试:

1  test.py -v

This should give you the same output as under Unix/Linux. After the tests are verified, you install the distribution by using the following command:
它将给出与在Un*x/Linux下相同的输出。 当测试校验成功后,用以下的安装分发版:

1  install.py -q install

You have now completed the installation of Zope 3. Now you can follow the final steps in the previous section to create an instance and start up Zope.
你现在完成Zope3的安装了。 接着进行前面章节的最后一步--创建一个实例并启动Zope。

Note: When you install Zope 3 in Windows without using make, it’s really hard to uninstall it later, because you have to manually delete files and directories from various locations, including your Python’s Lib“site-packages“ and Scripts“ directories. You also have to completely remove the zopeskel“ directory. If you use Windows Installer instead, an uninstallation program is provided and registered in the Control Panel’s Add/Remove Programs applet.[[BR]注意:这样的安装zope3使得它很难被卸载,因为你必须手工地从许多个位置上,包括Python的Lib\site-packages\和Scripts\目录,删除文件/目录,以及完全的删除zopeskel\目录。如果你使用Windows安装程序来代替,那么一个反安装程序将被提供并被注册到控制面板的"添加/删除程序"中。

1.5 Installing the Binary Distribution of Zope(安装二进制分发版)

Currently binary releases of Zope are available only for Windows. These releases assume that you have the standard Windows Python release installed. The Windows binary release is an executable that automatically executes Windows Installer. The first task is to make sure that you have the correct Python version installed. Zope X3.0 is released to work with Python 2.3. Thus, you need to install the latest Python 2.3 bug fix release. You can get the Windows binary installer at www.python.org/download/.
当前我们对于Windows仅仅提供二进制的发行版。这些发行版假定你已经安装了标准Windows Python发行版。Windows二进制的发行版是一个可执行文件,它将自动的执行安装程序。首先要确保你已经安装了 Python 的当前版本。Zope X3.0是基于 Python 2.3 工作的。因此,你需要安装 Python 的最新修正版。你可以在 http://www.python.org/download/ 得到 Windows 的二进制安装版。

If you already have a previous version of Zope X3, you need to remove it by using Add/Remove Programs from the Control Panel. Then you can install the Zope X3.0 release, which you can find at dev.zope.org/Zope3/Downloads. After you download it, you simply execute the installer and follow its instructions.
如果你已经有了 Zope X3 的前一个版本,你需要从控制面板中的使用添加/删除程序将其删除。然后你就可以安装 Zope X3.0 版了,你可以在 http://dev.zope.org/Zope3/Downloads 找到它。在你下载它之后,只需简单遵循屏幕上的安装向导。

When the install is complete, you need to open a Windows command prompt and change to the root Python 2.3 directory, usually "c:\python23". Then you execute the instance creation script using this:
当安装完成后,你需要打开一个 Windows 的命令行并进行 Python 的根目录,通常是“C:\python”。然后你使用下面的命令执行创建实例脚本:

1  .\python .\Scripts\mkzopeinstance -u username:password -d c:\path\to\instance

This completes the installation. You can now run Zope 3 by using this:
当结束之后,你现在可以用下面的语句开始运行 Zope 3:

1  .\python c:\path\to\instance\bin\runzope

The instance’s bin directory also contains some other useful scripts, such as the test runner.
实例的 bin 目录也包含了一些其它有用的脚本,如测试运行器。

You can later use the Control Panel’s Add/Remove Programs applet to uninstall Zope 3 again.
你也可以在以后使用控制面板的"添加/删除程序"工具再把 Zope 3 卸载掉。