Zope3宝典/序言

来自Ubuntu中文
Oneleaf留言 | 贡献2007年5月31日 (四) 09:27的版本 (新页面: == Chapter 0: Preface(第0章 序言) == The preface will be a brief introduction into Zope 3 and its capabilities as well as into Python , the programming language Zope is written...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航跳到搜索

Chapter 0: Preface(第0章 序言)

The preface will be a brief introduction into Zope 3 and its capabilities as well as into Python , the programming language Zope is written in.
序言是对 Zope 3 的一个简单的介绍,它的能力同编写 Zope 的 Python 程序语言一样强


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

原文作者:StephanRichter, zope.org

授权许可:创作共用协议

翻译人员:

校对人员:Leal, FireHare

适用版本:Zope 3

文章状态:校对阶段




What is Zope?(什么是Zope?)

What is Zope? While this sounds like a simple question that should be answered in a line or two, I often find myself in situations where I am unable to simple say: “It is an Open-Source Application Server.” or “It is a Content Management System.”. Both of these descriptions are true, but they are really putting a limit on Zope that simply does not exist. So before I will give my definition of Zope, let’s collect some of the solutions Zope has been used for. As mentioned above, many people use Zope as a Content Management System, which are usually Web-based (browser managed) systems. Basically the users can manage the content of a page through a set of Web forms, workflows and editing tools. However, there is an entirely different CMS genre, for which Zope also has been used. Other companies, such as struktur AG, used Zope successfully to interface with the XML Database Tamino (from software AG). The second common use is Zope as a Web-Application server, where it is used to build Web-based applications, such as online shops or project management tools. Of course, Zope is also suitable for regular Web sites.
什么是 Zope?这听起来应该是一个用一到两句话就能回答得简单的问题, 但我经常发现自己无法用简单的方式说明:“它是一个开放源码的应用服务器。它是一个内容管理系统。”。 这两个描述都是正确的, 但它们实际上是给 Zope 加上了其实并不存在的限制。因此在给出我对Zope的定义之前,让我们先收集一些已经使用了 Zope 的一些解决方案。依照以上提到的, 许多人使用 Zope 作为一个内容管理系统, 它们通常是基于互联网的(通过浏览器管理) 系统。基本上,用户可以通过一组web表单、工作流和编辑工具来管理页面内容。然而,Zope使用了一个完全不同的CMS流派。其他公司,例如struktur AG,成功地使用Zope连接了XML数据库Tamino (来自software AG)。Zope 第二个通常的用途就是作为一个 Web 应用服务器,用它可以建立基于 Web 的应用。例如:在线商店或者项目管理工具。当然,Zope也适合一般的网站。

And yet, there is a usage that we neglected so far. Zope can also be used as a reliable backend server managing the logistics of a company’s operations. In fact, bluedynamics.com in Austria built a logistic software based on Zope 2 ZClasses and a relational database that was able to handle hundreds of thousands transactions each day from taking credit card information and billing the customer up to ordering the products from the warehouse using XML-RPC. In my opinion this is the true strength of Zope, since it allows not only Web-familiar protocols to talk to, but also any other network protocol you can imagine. Zope 3, with its component architecture, accelerates even more in this area, since third party products can be easily plugged in or even replace some of the defaults. For example the Twisted framework can replace all of ZServer (the Zope Server components).
仍而, 到目前为止我们忽略一个用途。Zope 可以用作管理公司操作逻辑的后台服务器。事实上,奥地利的 bluedynamics.com 以 Zope2 ZClass 和关系数据库建立了一个后勤软件,每天可以处理数百万的交易,使用XML-RPC技术采集的信用卡信息和仓库的客户订单信息。在我看来,这是 Zope的真正力量。因为它不仅可以使用Web熟悉的协议来通信,更可以使用你能想象到的任何其他协来通信。Zope 3,它是组件架构的,更加促进了这个领域,因为第三方的产品可以很容易的嵌入甚至替换一些默认的组件。例如,Twisted framework就可以完全替换ZServer(Zope Server组件)。

Now that we have seen some of the common and uncommon uses of Zope it might be possible to formulate a more formal definition of Zope, just in case you are being asked at one point. Zope is an application and backend server framework that allows developers to quickly implement protocols, build applications (usually Web-based) and function as glue among other net-enabled services.
现在,我们已经了解了一些Zope普通的和少有的用途,我们可以对Zope下一个明确的定义了。Zope是一个应用,一个后台服务器框架可以让开发者快速建立协议,开发应用(通常是基于Web的)和整合其他使用网络的服务。

Before Zope was developed, Zope Corporation was reviewing many possible programming languages to develop the framework, such as Java, C/C++, Perl and Python. After extensive research they found that only Python would give them the competitive advantage in comparison to the other large framework providers, such as IBM, BEA and others.
在Zope开发之前,Zope团体评估了很多可能使用的语言来开发这个框架,例如:Java,C/C++,Perl和Python。经过了广泛的研究,他们发现只有Python才能提供给他们在与其他大型的框架提供商(例如,IBM,BEA等)比较时有竞争性的优势。

Powerful Python(强大的Python)

Python is a high-level object-oriented scripting language producing - by design - clean code through mandatory indentation. While Perl is also an interpreted scripting language, it lacks the cleanness and object-orientation of Python. Java, on the other hand, provides a nice object-oriented approach, but fails to provide powerful tools to build applications in a quick manner. So it is not surprising that Python is used in a wide variety of real world situations, like NASA, which uses Python to interpret their simulation data and connect various small C/C++ programs. Also, Mailman, the well-known mailing list manager, is being developed using Python. On the other hand, you have academics that use this easy-to-learn language for their introductory programming courses.
Python是一种高级的面向对象的脚本编程语言。通过缩进来实现整洁的代码。然而,Perl也是一种解释型的脚本语言,但是它缺少像Python 这样的整洁和面向对象的特性。另一方面,Perl提供了很好的趋近的面向对象,但是却缺少快速开发应用程序的工具。所以,Python来可以应用在各种各样的现实环境中,例如,NASA就是使用Python来准备模拟数据,并且连接各种各样的C/C++小程序。同样,Mailman,一个著名的邮件列表管理程序,也是使用Python开发的。另一方面,还有使用这个简单易学的语言作为编程入门课程的学院。

Since Python is such an integral part of the understanding of Zope, you should know it well. If you are looking for some introductory documentation, you should start with the tutorial that is available directly from the Python homepage http://www.python.org/doc/current/tut/tut.html. Also, there are a wide variety of books published by almost every publisher.
由于Python理解Zope来说至关重要,所以,你应该对它很熟悉。如果你正在找一些入门的文档,你可以从Python的主页 http: //www.python.org/doc/current/tut/tut.html 开始Python之旅。那里也有各种各样的已经出版的书。

In the beginning there was...(在开始的地方……)

Every time I am being asked to give a presentation or write a survey-like article about Zope, I feel the need to tell a little bit about its history, not only because it is a classic Open-Source story, but also because it gives some background on why the software behaves the way it does. So it should definitely not be missing here.
每当我被要求给出一个关于 Zope 的描述或写一篇类似调查的文章时,我都觉得有必要说说它的历史,不仅因为它是一个典型的开源故事,还因为它给出了一些为何软件要如此运作的背景。

Before Zope was born, Zope Corporation (which was originally named Digital Creations) developed and distributed originally three separate products called Bobo, Principia and Aqueduct. Bobo was an object publisher written in Python, which allowed one to publish objects as pages on the web. It also served as object database and object request broker (ORB), converting URLs into object paths. Most of this base was implemented by Jim Fulton in 1996 after giving a frustrating Python CGI tutorial at the International Python Conference. Even though Bobo was licensed under some sort of “free” license, it was not totally Open-Source and Principia was the commercial big brother.
在 Zope 出现之前,Zope 公司(起初叫 Digital Creations)制作发行了最初的三个独立的产品:Bobo、Principia 和 Aqueduct。Bobo 是用 Python 写的一个对象发布器,用来将对象作为 Web 页面发布。它还充当数据库对象和对象请求代理(ORB),将 URL 转换成对象路径。该库大部分是由 Jim Fluton 在1996年实现的,其后在国际 Python 协会已废除的 Python CGI 教程中给出。即使 Bobo 是基于部分“自由”协议,它并没有完全开源,而 Principia 则是一款商业软件。

In 1998, Hadar Pedhazur, a well-known venture capitalist, convinced Digital Creations to open up their commercial products and publish them as Open Source under the name Zope. Zope stands for the “Z Object Publishing Environment”. The first Zope release was 1.7 in December 1998. Paul Everitt, former CEO, and all the other people at Zope Corporation converted from a product company into a successful consultant firm. Alone the story how Zope Corporation went from a proprietary, product-based to a service-based company is very interesting, but is up to someone else to tell.
在1998年,Hadar Pedhazur,一位著名的投资人,坚持要 Digital Creations 将其商业产品开源,并取名为 Zope。Zope 是“Z 对象发布环境”的缩写。Zope 的第一个版本1.7版是在1998年12月发布的。Paul Everitt,前首席执行官,和 Zope 公司的其他人一起将一个产品公司成功地转成了一个顾问公司。关于 Zope 公司如何从一个私有的基于产品的公司转变成为一个基于服务的公司的故事是十分有趣的,但这已经超出了本书的内容。

In the summer of 1999, Zope Corporation published version 2.0, which will be the base for the stable release until Zope 3.0 will outdate it in the next few years. Zope gained a lot of popularity with the 2.x series; it is now included in all major Linux distributions and many books have been written about it. Originally I was going to write this book on the Zope 2.x API, but with the beginning of the Zope 3.x development in late 2001, it seemed much more useful to do the documentation right this time and write an API book parallel to the development itself. In fact when these lines were originally written, there was no Zope Management Interface , and the initial security had just been recently implemented.
1999年夏,Zope 公司发布了2.0版,对于稳定版本来说这将是主流,直到 Zope 3.0 在接下来的几年内将其逐步淘汰。Zope 通过 2.x 系列已经达到了许多目标;它现在被所有主流 Linux 发行版包含,而且有许多关于它的书。最初我打算用 Zope 2.0 API 来写本书,但随着 Zope 3.x 在2001年底开始开发,我觉得这次编写合适的文档更为有用,而且写 API 书等同于开发本身。实际上最初写下这些文字时,还没有 Zope 管理界面,也才刚刚实现了初步安全。

Zope 3 Components(Zope3组件)

Zope 3 will make use of many of the latest and hottest development patterns and technologies, and that with “a twist” as Jim Fulton likes to describe it. But Zope 3 also reuses some of the parts that were developed for previous versions. Users will be glad to find that Acquisition (but in a very different form) is available again as well as Zope Page Templates and the Document Template Markup Language - DTML (even though with less emphasis). Also, there is the consensus of a Zope Management Interface in Zope 3 again, but is completely developed from scratch in a modular fashion so that components cannot be only reused, but the entire GUI can be altered as desired.
Zope 3 使用许多最新最热的开发模式和技术,以及 Jim Fulton 喜欢说的“a twist”。但 Zope 3 也可以重用为以前版本开发的部分内容。用户将会很高兴地发现 Acquisition 可以再次使用(

But not only DTML, ZPT and Aquidition received a new face in Zope 3; external data handling has been also totally reworked to make external data play better together with the internal persistence framework, so that the system can take advantage of transactions, and event channels. Furthermore, the various external data sources are now handled much more generically and are therefore more transparent to the developer. But which external data sources are supported? By default Zope 3 comes with a database adaptor for Gadfly , but additional adapters for PostGreSQL and other databases already exist and many others will follow. Data sources that support XML-RPC, like the very scalable XML database Tamino, could also be seamlessly inserted. However, any other imaginable data source can be connected to Zope by developing a couple of Python modules, as described in various chapters.

During the last five years (the age of Zope 2) not only Zope was developed and improved, but also many third party products were written by members of the very active Zope community for their everyday need. These products range from Hot Fixes, Database Adaptors and Zope objects to a wide range of end user software, such as e-commerce, content management and e-learning systems. However, some of these products turned out to be generically very useful to a wide variety of people; actually, they are so useful, that they were incorporated into the Zope 3 core. The prime examples are the two internationalization and localization tools Localizer (by Juan David Ibáñez Palomar) and ZBabel (by me), whose existence shaped the implementation of the internationalization and localization support Zope 3 significantly. Another great product that made it into the Zope 3 core was originally written by Martijn Faassen and is called Formulator. Formulator allows the developer to define fields (representing some meta-data of a piece of content) that represent data on the one side and HTML fields on the other. One can then combine fields to a form and have it displayed on the Web. The second great feature Formulator came with was the Validator, which validated user-entered data on the server side. Formulator’s concepts were modularized into schemas and forms/widgets and incorporated in Zope 3.

Altogether, the framework is much cleaner now (and more pythonic) and features that failed to make it into the Zope 2 core were incorporated.

Goals of this book(本书的目标)

The main target audience for this book are developers that would like to develop on the Zope 3 framework itself; these are referred to as Zope developers in this book. But also Python programmers will find many of the chapters interesting, since they introduce concepts that could be used in other Python applications as well. Python programmers could also use this book as an introduction to Zope.

In general the chapters have been arranged in a way so that the Zope 3 structure itself could be easily understood. The book starts out by getting you setup, so that you can evaluate and develop with Zope 3. The second part of the book consists of chapters that are meant as introductions to various important concepts of Zope 3. If you are a hands-on developer like me, you might want to skip this part until you have done some development. The third and fourth part are the heart of the book, since a new content component with many features is developed over a course of 12 chapters. Once you understand how to develop content components, part five has a set of chapters that introduce other components that might be important for your projects. The fifth part is intended for people that wish to use Zope technologies outside of Zope 3. The emphasis on testing is one of the most important philosophical transitions the Zope 3 development team has undergone. Thus the last chapter is dedicated to various ways to write tests.

Last but not least this book should encourage you to start helping us to develop Zope 3. This could be in the form of enhancing the Zope 3 core itself or by developing third party products, reaching from new content objects to entire applications, such as an e-commerce system. This book covers all the modules and packages required for you to start developing.