⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 134.html

📁 Python Ebook Python&XML
💻 HTML
字号:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Robots" content="INDEX,NOFOLLOW">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Safari | Python Developer's Handbook -&gt; Distributing Objects with Python</TITLE>
<LINK REL="stylesheet" HREF="oreillyi/oreillyN.css">
</HEAD>
<BODY bgcolor="white" text="black" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="100%" cellpadding=5 cellspacing=0 border=0 class="navtopbg"><tr><td><font size="1"><p class="navtitle"><a href="8.html" class="navtitle">Web Development</a> &gt; <a href="0672319942.html" class="navtitle">Python Developer's Handbook</a> &gt; <a href="128.html" class="navtitle">7. Objects Interfacing and Distribution</a> &gt; <span class="nonavtitle">Distributing Objects with Python</span></p></font></td><td align="right" valign="top" nowrap><font size="1"><a href="main.asp?list" class="safnavoff">See All Titles</a></font></td></tr></table>
<TABLE width=100% bgcolor=white border=0 cellspacing=0 cellpadding=5><TR><TD>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="133.html" title="Implementing COM Objects in Python"><font size="1">&lt;&nbsp;BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0672319942&snode=134" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="134.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="135.html" title="Summary"><font size="1">CONTINUE&nbsp;&gt;</font></a></td></TR></TABLE>
<a href="5%2F31%2F2002+4%3A37%3A48+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>152015024128143245168232148039199167010047123209178152124239215162147035189200148107205159</font><a href="read5.asp?bookname=0672319942&snode=134&now=5%2F31%2F2002+4%3A37%3A48+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT>
				<h3>Distributing Objects with Python</h3>
				<p>There are some other packages that enable you to talk to other programs on platforms without <tT CLAss="monofont">COM</tt> support. As for the object distribution models, Python has many projects currently being developed.</P>

				<P>The <A Name="idx1073744663"></a><A NAMe="idx1073744664"></a><a name="idx1073744665"></a><a name="idx1073744666"></a><a name="idx1073744667"></a>Inter-Language Unification system (ILU) is a free and stable multi-language object interface system.</P>

				<p>The <a Name="idx1073744668"></A><a namE="idx1073744669"></a><a nAME="idx1073744670"></A><a namE="idx1073744671"></A><A Name="idx1073744672"></a>Object Request Broker is the mechanism that lets objects transparently make requests to梐nd receive from梠ther objects located locally or remotely. The ORB component is also commonly referred to as <A NAMe="idx1073744673"></a><a nAME="idx1073744674"></A><a name="idx1073744675"></a><a name="idx1073744676"></a><a name="idx1073744677"></a><i>CORBA,</i> which stands for <I>Common Object Request Broker Architecture.</i>
					<a Name="idx1073744678"></A><a namE="idx1073744679"></a><a nAME="idx1073744680"></A><a namE="idx1073744681"></A>omniORBpy is an almost complete implementation of the current Python CORBA mapping.</P>

				<P><a namE="idx1073744682"></A><A Name="idx1073744683"></a><A NAMe="idx1073744684"></a><a name="idx1073744685"></a>Fnorb is an Object Request Broker (ORB) that is compliant with the CORBA 2.0 specification from the Object Management Group (OMG). Fnorb implements a single language mapping from OMG IDL to Python. This implementation is excellent for those who want to learn CORBA. Another project worth mentioning is the <a name="idx1073744686"></a><a name="idx1073744687"></a><A naMe="idx1073744688"></a><a Name="idx1073744689"></a>ORBit-python project, which a binding for ORBit, the CORBA orb used by GNOME and some other projects.</P>

				<p><a nAME="idx1073744690"></A><a namE="idx1073744691"></A><A Name="idx1073744692"></a><A NAMe="idx1073744693"></a><a nAME="idx1073744694"></A>DCOM is the COM technology that distributes objects between different machines on the network. It defines a protocol that enables software components to communicate directly over a network in a reliable, secure, and efficient manner.<a name="idx1073744695"></a><a name="idx1073744696"></a><a name="idx1073744697"></a></p>

				<p>The <A naMe="idx1073744698"></a><a Name="idx1073744699"></a><A namE="idx1073744700"></A><A Name="idx1073744701"></a><A NAMe="idx1073744702"></a>Object Management Facility (OMF) is an object-oriented middleware environment for the process automation area. Even though it doesn't contain any Python code, it is heavily tested using Python scripts. The object model used by OMF is similar to other distributed object systems, such as OMG's CORBA and Xerox's ILU. OMF is implemented in C++, with APIs for other languages, including Python. It is said that the Python API was primarily created for writing test programs, but it has since been used to write various tools for application development and runtime management.</p>

				<p><A NAMe="idx1073744703"></a><a nAME="idx1073744704"></A><a name="idx1073744705"></a><a name="idx1073744706"></a>Hector is a distributed object system developed at the University of Queensland, Australia. It is written almost entirely in Python. Hector attempts to provide application objects with a consistent environment, regardless of their physical location, through a series of transparencies.</p>

				<h4>Inter-Language Unification (ILU)</h4>
					<p>The Inter-Language Unification system (ILU) is a free and stable multi-language object interface system, whose interfaces hide implementation distinctions between different languages, address spaces, and operating system types. ILU can be used to build multilingual, object-oriented class libraries with well-specified, language-independent interfaces. It can also be used to implement distributed systems and to define and document interfaces between the modules of nondistributed programs. ILU interfaces can be specified in either the OMG's CORBA Interface Definition Language (OMG IDL) or ILU's Interface Specification Language (ISL).</p>

					<p>ILU is primarily about interfaces between modules of program structure. Each module encapsulates the part of a program that has high adhesion internally and low connection to other parts of the program. The main goal of ILU is to create object-oriented interfaces that can communicate with those modules. ILU does all the translating and communicating necessary to use all kinds of modules in a single program. Its mechanism optimizes calls across module interfaces to involve only what it is necessary for the calling and called modules to interact. The notion of a module should not be confused with the independent concept of a program instance, which is translated as a combination of code and data running in one memory image, such as the UNIX processes.</p>

					<p>ILU standardizes many of the issues involved in providing proper inter-module independence, such as memory management and error detection and recovery strategies. ILU also includes an implementation of the Object Management Group's CORBA Internet Inter-Orb Protocol (IIOP), and can be used to write CORBA services or clients, as well. ILU provides a standard notation to write its interfaces桰SL, which stands for Interface Specification Language. ISL is a declarative language, which can be processed by computer programs that enables you to define exceptions, constants, object and non-object types. Next, you have a sample of what ISL looks like:<A naMe="idx1073744707"></a><a Name="idx1073744708"></a><A namE="idx1073744709"></A><A Name="idx1073744710"></a><A NAMe="idx1073744711"></a><a nAME="idx1073744712"></A><a namE="idx1073744713"></A></P>

					<Pre>
						
INTERFACE CalcMachine;
EXCEPTION DivideByZero;
TYPE Calculator = OBJECT
  METHODS
    SetValue (v : REAL),
    GetValue () : REAL,
    Divide (v : REAL) RAISES DivideByZero END
  END;

					</pre>

					<p>ILU provides a program, <a name="idx1073744714"></a><a name="idx1073744715"></a><a nAme="idx1073744716"></A><a naMe="idx1073744717"></a><tt ClasS="monofont">islscan,</TT> which can be used to check the syntax of an ISL specification, parse the specification, and summarize it to standard output.</P>

					<p>After you've defined an interface, you then need to supply an implementation of your module, which can be done in any language supported by ILU.</p>

					<p>The program <a NAME="idx1073744718"></a><a naME="idx1073744719"></A><A name="idx1073744720"></A><A NAme="idx1073744721"></a><tt class="monofont">python-stubber</tt> is used to read an ISL file, and generate all the Python code that is required to support the ISL interface. One of the files generated is <tt class="monofont">'Interface.py',</tT> which contains the definitions of all the Python types for that interface:</p>

					<pRe>
						
% python-stubber CalcMachine.isl
client stubs for interface "CalcMachine" to CalcMachine.py 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -