Differences between revisions 4 and 12 (spanning 8 versions)
Revision 4 as of 2008-12-07 05:53:56
Size: 5817
Editor: ShenXiaoFeng
Comment:
Revision 12 as of 2009-12-25 07:09:36
Size: 5858
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
[[TableOfContents]] <<TableOfContents>>
Line 7: Line 7:
[[Include(ZPyUGnav)]] <<Include(ZPyUGnav)>>
Line 9: Line 9:
== 13.1. "Tune In, Log On, and Drop Out" 收听,登入和脱离 (ShenXiaoFeng翻译中)==
Over the last decade, the Internet has virtually exploded onto the mainstream stage. It has rapidly grown from a simple communication device used primarily by academics and researchers into a medium that is now nearly as pervasive as the television and telephone. Social observers have likened the Internet's cultural impact to that of the printing press, and technical observers have suggested that all new software development of interest occurs only on the Internet. Naturally, time will be the final arbiter for such claims, but there is little doubt that the Internet is a major force in society, and one of the main application contexts for modern software systems.
== 13.1. "Tune In, Log On, and Drop Out" 收听,登入和脱离(沈小锋 翻译中)
Line 18: Line 17:
The Internet also happens to be one of the primary application domains for the Python programming language. It has been a decade since the first edition of this book was written as well, and in that time the Internet's growth has strongly influenced Python's tool set and roles. Given Python and a computer with a socket-based Internet connection today, we can write Python scripts to read and send email around the world, fetch web pages from remote sites, transfer files by FTP, program interactive web sites, parse HTML and XML files, and much more, simply by using the Internet modules that ship with Python as standard tools.
Line 23: Line 20:

In fact, companies all over the world do: Google, Yahoo!, Walt Disney, Hewlett-Packard, JPL, and many others rely on Python's standard tools to power their web sites. For example, the Google search enginewidely credited with making the web usablemakes extensive use of Python code. And the BitTorrent peer-to-peer file transfer systemwritten in Python and already downloaded by tens of millions of usersleverages Python's networking skills to share files among clients and remove server bottlenecks.

Many also build and manage their sites with the Zope web application server, which is itself written and customizable in Python. Others build sites with the Plone content management system, which is built upon Zope and delegates site content to its users. Still others use Python to script Java web applications with Jython (formerly known as JPython)a system that compiles Python programs to Java bytecode, exports Java libraries for use in Python scripts, and allows Python code to serve as web applets downloaded and run in a browser.
事实上,全世界很多大公司如Google, Yahoo!, Walt Disney, Hewlett-Packard, JPL等,都利用Python标准工作去建立它们强大的网站。举例说,google搜索引擎广泛使用Python代码来扩展网络的使用。BitTorrent(点对点文件传输软件)是用Python写的,超过千万的用户下载该软件并使用,在Python的网络处理技术的帮助下,用户突破了服务器的数据传输瓶颈来分享文件。
Line 30: Line 24:
More recently, XML-RPC and SOAP interfaces for Python, such as xmlrpclib and SOAPy, have enabled web service programming; frameworks such as CherryPy, Webware, TurboGears, and Django have emerged as convenient tools for constructing web sites; the new XML package in Python's standard library provides a suite of XML processing tools; and the new IronPython implementation promises to provide seamless .NET/Mono integration for Python code. 也有很多人使用Zope的网络框架服务器来建立与管理他们的网站,同样,Zope也是用Python来编写与定制的。也有人使用plone来建立网站,而plone是建立在Zope之上的。另外,还有人用Python语言生产java码,让其生产代码运行于java平台(JPython),这种扩展,也使得Python能使用Java函数库,也使得Python代码作为Web applets让浏览器下载与运行。

近来,Python也具备了Web Server编程的能力,因为Python有了XML-RPC和 SOAP的接口,如 xmlrpclib and SOAPy。一些框架如CherryPy, Webware, TurboGears, Django作为便利的建立网站的工作也出现。新的XML包出现,使Python有了处理XML的工具。 新的IronPython实现了Python代码与.NET/Mono的无缝结合。

随着网络的发展,Python在因特网工具中是一个重要的角色。Python已经证实是适合用于编写网络脚本,理由与它在其他领域一样,它使程序实现理想化。模块化的设计与快速编程的能力都适合网络开发的要求。在本书的这个部分,我们可以发现Python很好地支持网络脚本的编写。它使网络程序的开发质量(开发效率与可维护性)得到提高。

=== 13.1.1. Internet脚本主题 ===
##startInc
因特网编程包含很多主题,为了更好地让大家消化这些内容,本书接下来把这个主题分为六章。本章主要包括因特网基础与socket的探索,还有因特网底层通信机制。接下来,我们会讨论客户机、服务器、构建网站和更多高级的主题。


每一章的学习都是建基于前一章,当然如果你非常熟悉某些因特网的领域,你可以跳过这些内容往下阅读。这些章节都是本书的重要内容,所以,接下来我们会谈及更多的细节问题。


== 13.1.1.1.我们将会讨论的内容 ==
Line 34: Line 42:
As the Internet has grown, so too has Python's role as an Internet tool. Python has proven to be well suited to Internet scripting for some of the very same reasons that make it ideal in other domains. Its modular design and rapid turnaround mix well with the intense demands of Internet development. In this part of the book, we'll find that Python does more than simply support Internet scripts; it also fosters qualities such as productivity and maintainability that are essential to Internet projects of all shapes and sizes. 在概念层面,因特网可以大致分为几个功能层:
Line 36: Line 44:
=== 13.1.1. Internet Scripting Topics ===
##startInc
Internet programming entails many topics, so to make the presentation easier to digest, I've split this subject over the next six chapters of this book. This chapter introduces Internet fundamentals and explores sockets, the underlying communications mechanism of the Internet. From there, later chapters move on to discuss the client, the server, web site construction, and more advanced topics.
Low-level networking layers(物理层)
Line 40: Line 46:
Each chapter assumes you've read the previous one, but you can generally skip around, especially if you have any experience in the Internet domain. Since these chapters represent a substantial portion of this book at large, the following sections go into a few more details about what we'll be studying.     Mechanisms such as the TCP/IP transport mechanism, which deal with transferring bytes between machines, but don't care what they mean
Line 42: Line 48:
== 章标题1 ==
=== 小节标题1 ===
{{{
#!python
Python code
}}}
Sockets(接口层)

    The programmer's interface to the network, which runs on top of physical networking layers like TCP/IP

Higher-level protocols(协议层)

    Structured communication schemes such as FTP and email, which run on top of sockets and define message formats and standard addresses

Server-side web scripting (CGI)

    Higher-level client/server communication protocols between web browsers and web servers, which also run on top of sockets

Higher-level frameworks and tools(更高级的框架与工具)

    Third-party systems such as Zope and Jython, which address larger problem domains


在本章与第十四章,我们主要讨论在第二层与第三层协议(接口层与协议层)的网络编程。接下来,我们会学习网络编程的接口模型。接口虽然不是与我们的网络脚本紧密相关,但是接口在网络中有着重要的角色,无论你是否留意到,因特网的运作都是通过接口发生的。

在介绍接口后,接下来两章,我们会实现Python的客户端程序接口,如email与ftp传输,这些都是协议是实现在socket之上的。Python已经能完成客户端的很多工作,再接下来的两章,我们会转到服务器端脚本编程,程序运行于服务器,能被浏览器使用。最后,这部分的最后一章(18章)将会介绍更高级的主题如JPython与Zope。

同时,我们将会用上一些前面章节所学的操作系统和图形接口(进程、线程、信号与Tkinter),在因 特网的开发中,我们把这些知识整合到其中。

在最后,我们说下因特网脚本的一些优点,就如GUIs,都是Python一个成熟的程序领域。

Line 53: Line 79:
||<style="vertical-align: top;">[[PageComment2]]||<style="vertical-align: top;">[:PP3eD/Ch-13-1/PageCommentData:PageCommentData]'''' ||

== 13.1. "Tune In, Log On, and Drop Out" 收听,登入和脱离(沈小锋 翻译中)

在过去十几年,因特网技术事实上已经发展成主流技术。它的快速发展,使这种本来是大专院校里,研究者之间一种简单的交流设备,现在变成广泛的信息交流媒介,在电视机与电话机之间也可交流信息。社会学者把因特网文化影响的重要性比作当年印刷机的出现。技术学者还认为以后的软件发展应该建基于因特网。一些相关的言论,最后将随着时间得出结论,但不用置疑的是,因特网已经成为影响社会的重要力量,也是现代计算机软件系统的一个主要应用领域。

Python编程语言的一个重要的应用领域就是因特网。这本书的第一版书写到现在的十年间,因特网飞速发展,影响着Python语言的工具集的发展和Python的角色变化。给我们一台连着网络的计算机与Python编程环境,我们就能写着Python脚本来收发电邮,从远程的服务器抓取网页,用FTP传输文件,做交互式的网站,分析HTML和XML文件。做这么多的工作,其实就是简单地利用了Python的Internet modules(因特网模块)。

事实上,全世界很多大公司如Google, Yahoo!, Walt Disney, Hewlett-Packard, JPL等,都利用Python标准工作去建立它们强大的网站。举例说,google搜索引擎广泛使用Python代码来扩展网络的使用。BitTorrent(点对点文件传输软件)是用Python写的,超过千万的用户下载该软件并使用,在Python的网络处理技术的帮助下,用户突破了服务器的数据传输瓶颈来分享文件。

也有很多人使用Zope的网络框架服务器来建立与管理他们的网站,同样,Zope也是用Python来编写与定制的。也有人使用plone来建立网站,而plone是建立在Zope之上的。另外,还有人用Python语言生产java码,让其生产代码运行于java平台(JPython),这种扩展,也使得Python能使用Java函数库,也使得Python代码作为Web applets让浏览器下载与运行。

近来,Python也具备了Web Server编程的能力,因为Python有了XML-RPC和 SOAP的接口,如 xmlrpclib and SOAPy。一些框架如CherryPy, Webware, TurboGears, Django作为便利的建立网站的工作也出现。新的XML包出现,使Python有了处理XML的工具。 新的IronPython实现了Python代码与.NET/Mono的无缝结合。

随着网络的发展,Python在因特网工具中是一个重要的角色。Python已经证实是适合用于编写网络脚本,理由与它在其他领域一样,它使程序实现理想化。模块化的设计与快速编程的能力都适合网络开发的要求。在本书的这个部分,我们可以发现Python很好地支持网络脚本的编写。它使网络程序的开发质量(开发效率与可维护性)得到提高。

13.1.1. Internet脚本主题

因特网编程包含很多主题,为了更好地让大家消化这些内容,本书接下来把这个主题分为六章。本章主要包括因特网基础与socket的探索,还有因特网底层通信机制。接下来,我们会讨论客户机、服务器、构建网站和更多高级的主题。

每一章的学习都是建基于前一章,当然如果你非常熟悉某些因特网的领域,你可以跳过这些内容往下阅读。这些章节都是本书的重要内容,所以,接下来我们会谈及更多的细节问题。

13.1.1.1.我们将会讨论的内容

在概念层面,因特网可以大致分为几个功能层:

Low-level networking layers(物理层)

  • Mechanisms such as the TCP/IP transport mechanism, which deal with transferring bytes between machines, but don't care what they mean

Sockets(接口层)

  • The programmer's interface to the network, which runs on top of physical networking layers like TCP/IP

Higher-level protocols(协议层)

  • Structured communication schemes such as FTP and email, which run on top of sockets and define message formats and standard addresses

Server-side web scripting (CGI)

  • Higher-level client/server communication protocols between web browsers and web servers, which also run on top of sockets

Higher-level frameworks and tools(更高级的框架与工具)

  • Third-party systems such as Zope and Jython, which address larger problem domains

在本章与第十四章,我们主要讨论在第二层与第三层协议(接口层与协议层)的网络编程。接下来,我们会学习网络编程的接口模型。接口虽然不是与我们的网络脚本紧密相关,但是接口在网络中有着重要的角色,无论你是否留意到,因特网的运作都是通过接口发生的。

在介绍接口后,接下来两章,我们会实现Python的客户端程序接口,如email与ftp传输,这些都是协议是实现在socket之上的。Python已经能完成客户端的很多工作,再接下来的两章,我们会转到服务器端脚本编程,程序运行于服务器,能被浏览器使用。最后,这部分的最后一章(18章)将会介绍更高级的主题如JPython与Zope。

同时,我们将会用上一些前面章节所学的操作系统和图形接口(进程、线程、信号与Tkinter),在因 特网的开发中,我们把这些知识整合到其中。

在最后,我们说下因特网脚本的一些优点,就如GUIs,都是Python一个成熟的程序领域。


  • 反馈

创建 by @ShenXiaoFeng@ [@20081107@]

PP3eD/Ch-13-1 (last edited 2009-12-25 07:09:36 by localhost)