Zope简介

之前一直使用Django在开发web应用, 觉得Django易学, 好用. 后来看到Zope, 觉得两者的scope有重合, 所以大概学习了下Zope, 记录一下.

了解Zope可以先看看这篇Blog, zope系列一: zope的悲剧 (http://www.douban.com/group/topic/11400495/)

Zope(Z Object Publishing Environment)是一个企业级的web应用服务器的开发平台, 它很强大, 也比较复杂, 所以从某种程度上而言, 它无法被Python社区所接受, 因为它不够简单和美丽, 而python的哲学是大道至简. 由于推广问题, 策略问题, 等等问题导致这样一个平台没有红起来, 但是毋庸置疑它很牛, 很值得学习, 因为基于它开发出了Plone (Plone是免费的、开放源代码的内容管理系统(Content Management System,CMS)), 我个人没用过, 据说相当强大, 相当牛...所以我就先简单学习一下, 等以后用到再仔细研究吧.

以下内容来自Zope Book,

Fundamental Zope Concepts

Object Orientation
Unlike common file-based Web templating systems such as ASP or PHP, Zope is a highly "object-oriented" Web development platform.
Zope不同于其他web开放框架的是, 他不是基于文件的, 之前我们在使用jsp, 或django, 都是基于文件的, 而Zope是完全基于对象的, 任何东西, 网页模板, 逻辑代码, 数据都抽象为对象.

Object Publishing
The technology that would become Zope was founded on the realization that the Web is fundamentally object-oriented.
A URL to a Web resource is really just a path to an object in a set of containers, and the HTTP protocol provides a way to send messages to that object and receive its response.
既然基于对象, 所以就是基于对象的发布, 任何URL都是访问某一对象, 或发送message给某对象. 而不象一般的开放框架, 是基于文件发布的.

Through-The-Web Management
To create and work with Zope objects, you use your Web browser to access the Zope management interface. All management and application development can be done completely through the Web using only a browser.
这点是Zope很牛比的地方, 你只需要通过浏览器去访问Zope服务器, 就能完成任何服务器的管理, 更牛的是, 你还可以完成应用的开发. 可以想象, 只需要一台Zope服务器, 你可以在任何地方方便的管理并开发应用. 多么美好的场景.

Security and Safe Delegation
One of the things that sets Zope apart from other application servers is that it was designed from the start to be tightly coupled not only with the Web object model, but also the Web development model. Today's successful Web applications require the participation of many people across an organization who have different areas of expertise. Zope is specifically designed to accommodate this model, allowing site managers to safely delegate control to design experts, database experts and content managers.
Objects in Zope provide a much richer set of possible permissions than a conventional file-based system. Permissions vary by object type based on the capabilities of that object. This makes it possible to implement fine-grained access control.
对于一个大型的Web应用而言, 需要很多角色的开发者, 当他们协同开发的时候, 出于安全性和可维护性的考虑, 需要分配不同的权限, Zope对这个也有很好的支持.

Native Object Persistence and Transactions
Zope objects are stored in a high-performance transactional object database known as the Zope Object Database (ZODB). Each Web request is treated as a separate transaction by the object database.The Zope framework makes all of the details of persistence and transactions totally transparent to the application developer.The Zope framework makes all of the details of persistence and transactions totally transparent to the application developer.
Zope Object Database (ZODB), Zope不但提供开放框架, 还提供了一套面向对象数据库的solution来支持它的面向对象发布, 而其他开发框架往往都是基于现有的关系数据库.
据说这个数据库很好用, 很牛比, 现在流行的No Sql数据库都没这个牛, 没研究过, 没发言权.
等后面有空了, 来好好研究一下这个数据库.

Acquisition
One of the most powerful aspects of Zope is "Acquisition", and the core concept is simply that:
 ·  Zope objects are contained inside other objects (such as Folders).
 ·  Objects can "acquire" attributes and behavior from their containers.
这个是Zope在它的对象层次架构上的一个创新, 这个概念是Zope发明的, 以前没有听说过. 其实很简单, 就是基于包含(contain)关系的功能继承.
说白了, Object可以继承container的behavior. 这非常适合Zope的对象层次架构, 很像文件系统, 一级一级不断的包含下去, 所以非常便于service的提供和发布.

Zope Is Extensible
Zope is highly extensible, and advanced users can create new kinds of Zope objects, either by writing new Zope add-ons in Python or by building them completely through the Web. 

 

Fundamental Zope Components

下面列出Zope的架构图,

ZServer — Zope comes with a built in web server that serves content to you and your users. This web server also serves Zope content via FTP, WebDAV, and XML-RPC (a remote procedure call facility).
Web Server — Of course, you may already have an existing web server, such as Apache or Microsoft IIS and you may not want to use Zope's. Zope works with these web servers also, and any other web server that supports the Common Gateway Interface (CGI).
Zope本身就提供ZServer, 如果你喜欢用其他的Server, 如Apache...随便

Zope Core — This is the engine which coordinates the show, driving the management interface and object database.
这个就是核心engine, 用来run这个Zope server

Object Database — When you work with Zope, you are usually working with objects that are stored in Zope's object database.
Relational database — You don't have to store your information in Zope's object database if you don't want to. Zope works with other relational databases such as Oracle , PostgreSQL , Sybase , MySQL and others.
File System — Zope can of course work with documents and other files stored on your server's file system.
Zope开发了很牛比的面向对象数据库, 你可以把一齐都当对象存进去. 当然你如果想用, 关系型数据库和文件系统, 也没问题.

ZClasses — Zope allows site managers to add new object types to Zope using the Zope Management Interface. ZClasses are these kinds of objects.
Products — Zope also allows site managers to add new object types to Zope by installing "Product" files on their Zope server's filesystem.

 

Using Basic Zope Objects

对于Zope的核心就是对象, 下面就来介绍一下Zope对象, 这就是典型的MVC架构...
In general, basic Zope objects take on one of three types of roles:

Content — Zope objects such as documents, images and files hold different kinds of textual and binary data. In addition to objects in Zope containing content, Zope can work with content stored externally, for example, in a relational database.

Presentation — You can control the look and feel of your site with Zope objects that act as web page "templates". Zope comes with two facilities to help you manage presentation: DTML (which also handles "logic"), and Zope Page Templates (ZPT). The difference between DTML and ZPT is that DTML allows you to mix presentation and logic, while ZPT does not.

Logic — Zope has facilities for scripting business logic. Zope allows you to script behavior using three facilities: Document Template Markup Language (DTML), Python, and Perl (Perl is only available as an add-on).

Content Objects: Folders, Files, and Images

Folders
You've already met one of the fundamental Zope objects: the Folder . Folders are the building blocks of Zope. The purpose of a folder is simple: a Folder's only job in life is contain other objects.Folders can contain any other kind of Zope object, including other folders. You can nest folders inside each other to form a tree of folders. Good structure is very important, as Zope security and presentation is influenced by your site's folder structure.

Files
Zope Files contain raw data, just as the files on your computer do. Files do not consider their contents to be of any special format, textual or otherwise. Every File object has a particular content type which is a standard Internet MIME designation for types of content.

Images
Image objects contain the data from image files such as GIF, JPEG, and PNG files.

Presentation Objects: Zope Page Templates and DTML Objects

Zope Page Templates are objects which allow you to define dynamic presentation for a web page. The HTML in your template is made dynamic by inserting special XML namespace elements into your HTML which define the dynamic behavior for that page.
<title tal:content="here/title">Page Title</title>

Document Template Markup Language objects are object which also allow you to define presentation for a web page. The HTML in your template is made dynamic by inserting special "tags" (directives surrounded by angle brackets, typically) into your HTML with define the dynamic behavior for that page.
<dtml-in mySequence>
    <!-- this is an HTML comment inside the in tag block -->
</dtml-in>

Both ZPT and DTML are "server-side" scripting languages, like SSI, PHP, embperl, or JSP. This means that DTML and ZPT commands are executed by Zope on the server, and the result of that execution is sent to your web browser.

Zope's original dynamic presentation language was DTML. It soon became apparent that DTML was great at allowing programmers to quickly generate dynamic web pages, but many times failed at allowing programmers to work effectively together with nontechnical graphics designers. Thus, ZPT was born. ZPT is an "attribute-based" presentation language that tries to allow for the "round-trippping" of templates between programmers and nontechnical designers.

大家是否都觉得, 为什么需要两个View solution, 是啊, 这就是Zope灵活的地方, 你想怎么用就怎么用, 但是这就违反了python的简单原则, 对于一个问题, 最好只有唯一的答案, 太多选择有时候也是件烦恼的事.上面也说了, 本来是只有DTML的, 它很灵活, 适用于开发者, 不但可以开放view, 里面可以加上logic, 这样虽然影响MVC分层的理念, 但只要做过相关开发都应该体会到, 绝对的分开view和logic,有时候是很麻烦的, 很不实用的, 虽然看上去很美. 他最大的问题就是, 直接在Html增加Tag, 这样开发的view是无法直接用浏览器预览的,因为他的结果非标准Html, 有很多自定义的Tag. 这样就无法和UI设计人员合作开发, 你无法要求UI人员熟悉使用DTML, 而他用HTML设计的UI模板, 在DTML里无法直接使用.
所以产生了 Zope Page Templates (ZPT ), 它只会在Html属性上加上特殊的XML命名空间, 这样是不影响网页被浏览器预览的, 这样就解决了刚才的问题, 不过ZPT不允许插入任何逻辑, 对于开发人员而言不是那么方便, 各有所长, 爱用谁用谁......

Logic Objects: Script (Python) Objects and External Methods

"Logic" objects in Zope are objects which typically perform some sort of "heavy lifting" or "number crunching" in support of presentation objects.

 

Acquisition

Acquisition is the technology that allows dynamic behavior to be shared between Zope objects via containment .
Acquisition's flavor permeates Zope. It can be used almost everywhere within Zope: in DTML, in Zope Page Templates, in Script (Python) objects, and even in Zope URLs. Because of its ubiquity in Zope, a basic understanding of acquisition is important.

Acquisition vs. Inheritance

Inheritance stipulates that an object can learn about its behavior from its superclasses via an inheritance hierarchy .
Acquisition , on the other hand, stipulates that an object can additionally learn about its behavior its through its containment hierarchy . In Zope, an object's inheritance hierarchy is always searched for behavior before its acquisition hierarchy. If the method or attribute is not found in the object's inheritance hierarchy, the acquisition hierarchy is searched.

本文章摘自博客园,原文发布日期:2011-07-05

时间: 2024-09-20 09:40:47

Zope简介的相关文章

Python之路【1】:Python简介和入门

Python之路[第一篇]:Python简介和入门 python简介: 一.什么是python Python(英国发音:/ pa θ n/ 美国发音:/ pa θɑ n/),是一种面向对象.直译式的计算机程序语言. 每一门语言都有自己的哲学: pythonde 设计哲学是:"优雅"."明确"."简单" 二.python由来  1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继承.之

Python中title()方法的使用简介

  这篇文章主要介绍了Python中title()方法的使用简介,是Python入门中的基础知识,需要的朋友可以参考下 title()方法返回所有单词的第一个字符大写的字符串的一个副本. 语法 以下是title()方法的语法: ? 1 str.title(); 参数 NA 返回值 此方法返回其中所有单词的前几个字符都是大写的字符串的一个副本. 例子 下面的例子显示了title()方法的使用. ? 1 2 3 4 #!/usr/bin/python   str = "this is string

shiro(1)-简介

简介 apache shiro 是一个功能强大和易于使用的Java安全框架,为开发人员提供一个直观而全面的的解决方案的认证,授权,加密,会话管理. 在实际应用中,它实现了应用程序的安全管理的各个方面. shiro的功能 apache shiro能做什么? 支持认证跨一个或多个数据源(LDAP,JDBC,kerberos身份等) 执行授权,基于角色的细粒度的权限控制. 增强的缓存的支持. 支持web或者非web环境,可以在任何单点登录(SSO)或集群分布式会话中使用. 主要功能是:认证,授权,会话

Tutum公司简介

2015年10月21日,由Tutum公司的CEO Borja Burgos对外宣布,Tutum与Docker公司正式合作,大家对Tutum和Docker的合作还是很期待的.下面我简单介绍一下Tutum公司. Tutum的历史 Tutum创立的时间很难确定.Tutum(拉丁语里安全的意思)的最初构思是在2012年秋季,它是作为Borja Burgos在卡内基梅隆大学(匹兹堡)的研究生课程和在日本兵库县大学的硕士论文,Tutum是一个可以帮助企业过渡到云的安全支持系统. 在2013年初,Tutum有

在应用中加入全文检索功能——基于Java的全文索引引擎Lucene简介

全文检索|索引 内容摘要: Lucene是一个基于Java的全文索引工具包. 基于Java的全文索引引擎Lucene简介:关于作者和Lucene的历史 全文检索的实现:Luene全文索引和数据库索引的比较 中文切分词机制简介:基于词库和自动切分词算法的比较 具体的安装和使用简介:系统结构介绍和演示 Hacking Lucene:简化的查询分析器,删除的实现,定制的排序,应用接口的扩展 从Lucene我们还可以学到什么 基于Java的全文索引/检索引擎--Lucene Lucene不是一个完整的全

Linux Namespace机制简介

最近Docker技术越来越受到关注,作为Docker中很重要的一项技术,Namespace也就经常在Docker的简介里面看到. 在这里总结一下它的内部机制.也解决一下自己原来的一些疑惑. Namespace是什么: C++中的Namespace: 首先,先提一下Namespace是什么.最早知道这个名词是在学习C++语言的时候.由于现在的系统越来越复杂,代码中不同的模块就可能使用相同变量,于是就出现了Namespace,来对全局作用域进行划分. 比如C++的标注库都定义在STD Namespa

ENode 2.6 架构与设计简介以及全新案例分享

前言 ENode是一个应用开发框架,为开发人员提供了一整套基于DDD+CQRS+ES+EDA架构风格的解决方案.ENode从发布1.0开始到现在的差不多两年时间,我几乎每周都在更新设计或实现代码.以至于从来没有一个稳定的版本可以提供给大家,非常惭愧.但我相信,随着时间的推移和我的努力的积累,ENode一定会越来越稳定和成熟的.我觉得我此刻很幸福,因为我有自己的兴趣且有机会在业余时间为了自己的兴趣而奋斗. ENode开源地址:https://github.com/tangxuehua/enode

linux内核符号表kallsyms简介

在使用perf排查问题时,我们经常会发现[kernel.kallsyms]这个模块.这到底是个什么东西呢? 简介: 在2.6版的内核中,为了更方便的调试内核代码,开发者考虑将内核代码中所有函数以及所有非栈变量的地址抽取出来,形成是一个简单的数据块(data blob:符号和地址对应),并将此链接进 vmlinux 中去. 在需要的时候,内核就可以将符号地址信息以及符号名称都显示出来,方便开发者对内核代码的调试.完成这一地址抽取+数据快组织封装功能的相关子系统就称之为 kallsyms. 反之,如

Python中Django框架下的staticfiles使用简介

  这篇文章主要介绍了Python中Django框架下的staticfiles使用简介,staticfiles是一个帮助Django管理静态资源的工具,需要的朋友可以参考下 django1.3新加入了一个静态资源管理的app,django.contrib.staticfiles.在以往的django版本中,静态资源的管理一向都是个问题.部分app发布的时候会带上静态资源文件,在部署的时候你必须手动从各个app中将这些静态资源文件复制到同一个static目录.在引入staticfiles后,你只需