个人工具
登录
查看“Zope3宝典/新Web用户界面”的源代码 - Ubuntu中文
页面
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“Zope3宝典/新Web用户界面”的源代码
来自Ubuntu中文
←
Zope3宝典/新Web用户界面
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
=== 2.4 The Content Versus the Software Space(内容空间 VS 软件空间) === Zope 2 makes a great mistake by allowing software and content to live in the same place. Zope’s developers did not want to repeat the same mistake in version 3. Therefore, they developed a content space and a software space. So far in this book you have only worked in the content space.<br>Zope2在允许软件和内容放在同一空间上犯了一个巨大的错误。我们不想在Zope3中犯同样的错误。因此,我们开发了一个"内容空间"和"软件空间"。到目前为止,我们一直在内容空间里。 ==== 2.4.1 Content Space(内容空间) ==== As the name implies, the content space only stores content. Whereas simple DTML and ZPT scripts are dynamic content, Python scripts are clearly software and are therefore not available in the content space. The only type of programming that is supported there is scripter support. However, being a scripter in this sense is not desirable, and Zope’s developers want to provide a way to help a scripter become a TTW developer. .<br>正如名字,在内容空间里我们只存储内容。我们可以将DTML和ZPT认为是一种动态内容,而Python脚本明显是软件,并且不能存放在内容空间里。在这里唯一支持的编程类型就是脚本。然而,"脚本"感觉上并不是很好,我们正准备为脚本人员提供一个变成 TTW 开发人员的途径。 ==== 2.4.2 Software Space(软件空间) ==== Every Site object has a software space, which can be accessed via the Manage Site action. You can see the link when you are looking at the contents of the root folder because the root folder is always a site. But because it is not on the list of addable types, how do you create a Site object? To create a site, you create a folder, enter the folder by clicking on its name, and click the Make a Site action item. That’s it! Any folder can be upgraded to a site.<br>每一个"Site"对象都有一个软件空间,可以通过"Manage Site"动作来访问。当查看根文件夹的内容时你就可以看到这个链接,因为根文件夹总是一个站点。但是,怎样创建一个新的呢?它并不在可添加类型的列表里呀?为了创建一个站点,先创建一个文件夹,然后点击动作菜单上的"Make a site"链接。就是它!任何文件夹都可以通过这个途径升级为一个站点。 After the site is created and you click Manage Site, you are presented with an overview of possible tasks to do. Each site consists of several packages, including the default package, which is always defined. Packages are used to later pack up and distribute software. An involved registration and constraint system ensures the integrity of the setup.<br>一旦你点击了"Manage Site",一个任务概要将展示在你的面前。每一个站点都由一些包组成,包括默认的包,总是定义过的。包被用来打包和发布软件。一个相关的注册与约束系统保证了安装的正确性。 If you now click the Visit Default Folder action link, you end up in the Contents view of the package. The goal is to add local components here that act as software. Because this looks and behaves very similar to the folder’s content space’s Contents view, the added components are called metacontent.<br>如果你现在点击"Visit default folder"链接,你将看到包的内容视图。目标是你在这里加入本地组件作为软件来使用。由于这个看上去与文件夹的内容空间的"内容"视图很像,所以我们经常把添加的组件称为"元内容"。 Let’s look at how all this hangs together. The simplest example is to create a local Translation Domain utility and use it to translate a silly message:好了,现在让我们看看这些是如何挂接在一起的。最简单的例子就是创建一个本地翻译域,然后用它翻译一条无聊的消息: * In the Contents view of the default package, click Add, select Translation Domain, and enter Translations as the name. Then press the Add button to submit the request. You are then prompted to register the component.<br>在缺省包的内容视图中,点击“Add”,选择“Translation Domain”,键入“Translations”做为名称,然后点击“Add”按钮提交。随后提示你注册组件。 * Create a registration by clicking Register.<br>点击“Register”创建一个注册。 * Register the domain under the name silly (which will be the official domain name). The provided interface should be <code><nowiki>ILocalTranslationDomain</nowiki></code>, and the registration status should be set to Active. Finish the request by clicking the Add button. Now you have an active Translation Domain utility.<br>在 silly (这个将成为正式的域名)名字下注册域。提供的接口应该是 <code><nowiki>ILocalTranslationDomain</nowiki></code>,注册的状态应该设为 Active。点击“Add”按钮完成。现在你有一个激活了的 Translation Domain 工具。 * Click the Translate tab to enter the translation environment.<br>点击“Translate”标签进入翻译环境。 * In the translation environment, add some languages. Enter en under New Language and click the Add button. Do the same for de. Then select both English ( en) and German ( de) from the list on the left and click Edit. The table further down the page grows by two columns, each representing a language.<br>在翻译环境中,添加一些语言。在"New Language"下面输入en,然后按"Add"按钮。同样的方法输入de。现在你必须同时选中2个,英语和德语,然后点击"Edit"。你将看到表格的下面多出来两栏,每一栏代表一种语言。 * To add a new translation, look at the first row. For the message ID, enter greeting, and for the de and en columns add Hallo´Welt! and Hello´World!, respectively.<br>要添加一个新的翻译项,请看第一行。 对于Message Id,输入"greeting",对于de 和en 栏,分别输入"Hallo Welt!"和"Hello World!"。 * To save the new translation, press the Edit Messages button at the bottom of the screen. You now have a translation of the greeting into English and German.<br>点击屏幕底部的"Edit Messages"按钮来保存这个新的翻译项。你此刻有一个将greeting翻译成英语和德语的翻译项了。 The translation screen can be seen in Figure 2.7<br>翻译屏幕请参见图2.7 attachment:figure_2_7.png Figure 2.7: The Translate screen of the Translation Domain utility.<br>图2.7:Translation Domain 工具的翻译屏幕 Now that you have defined the software--the Translation Domain utility--it is time to go back to the content space and use the new software. In the root folder, you need to create a new ZPT page called i18n.html and add the following content to it:<br>我们已经定义了我们的软件-Translation Domain 工具,现在是时候回到内容空间并"使用"这个新软件了。 在根目录创建一个新的ZPT页面,叫做"i18n.html"并添加如下的内容: <pre><nowiki> 1 <html> 2 <body i18n:domain="silly"> 3 <h1 i18n:translate="">greeting</h1> 4 </body> 5 </html> </nowiki></pre> When you save these lines and click the Preview tab, with English as the preferred language, you see a big Hello World! onscreen. If you change the language to German ( de), Hallo´Welt! should appear.<br>当你保存这些行并点击"预览"标签之后,你将看到一个巨大的"Hello World!",假定你是将英语指定为默认语言的。 '''''Note: '''In Mozilla you can change the preferred language by selecting Edit, Preferences, Navigator, Languages. Then you simply add German ( de) and move it to the top of the list.<br>'''注意:'''在 Mozilla 中你可以选择 <code><nowiki>Edit/Preferences/Navigator/Languages</nowiki></code> 来改变首选的语言编码,然后你简单添加German(de)并将其移至列表的顶部'' You have seen how simple it is to develop software in a site and then use it in the content space. As Zope 3 matures, it will offer much more impressive features, such as new views and TTW development of content components using schemas.<br>我们已经看到了在站点里开发一个软件并将其应用到内容空间的过程是多么的简单。随着Zope3越来越成熟,你将会看到更加激动人心的特色,比如使用Schemas来进行内容组件的TTW开发和写新视图。 This concludes our brief trip into the land of TTW development. After talking a little bit more about setting up Zope, we will turn to filesystem-based development and start take a more formal look at the concepts in Zope 3. <br>这些将把我们带到"通过网络(TTW)"的开发环境。在更多地了解了更多有关安装Zope的内容后,我们将要转向基于文件系统的开发并开始对Zope3的观念给出一个更加正式的介绍。
返回至
Zope3宝典/新Web用户界面
。