Sophie

Sophie

distrib > Mandriva > 10.1 > i586 > by-pkgid > ccf83290023404568bb21aa0163b385f > files > 1067

python-docs-2.3.4-6.2.101mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="mac.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.gif" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="mac.html" title='Macintosh Library Modules' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<LINK rel="next" href="module-aetypes.html">
<LINK rel="prev" href="module-aetools.html">
<LINK rel="parent" href="scripting.html">
<LINK rel="next" href="module-aetypes.html">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name='aesop' content='information' />
<META name="description" content="aepack -- Conversion between Python variables and AppleEvent data containers">
<META name="keywords" content="mac">
<META name="resource-type" content="document">
<META name="distribution" content="global">
<title>3.3 aepack -- Conversion between Python variables and AppleEvent data containers</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="3.2 aetools  " 
  href="module-aetools.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="3. MacPython OSA Modules" 
  href="scripting.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="3.4 aetypes  " 
  href="module-aetypes.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Macintosh Library Modules</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents" 
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index" 
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-aetools.html">3.2 aetools  </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="scripting.html">3. MacPython OSA Modules</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-aetypes.html">3.4 aetypes  </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION005300000000000000000">
3.3 <tt class="module">aepack</tt> --
         Conversion between Python variables and AppleEvent data containers</A>
</H1>

<P>
<A NAME="module-aepack"><!--z--></A>  
<p class="availability">Availability: <span
 class="platform">Macintosh</span>.</p>

<P>
The <tt class="module">aepack</tt> module defines functions for converting (packing)
Python variables to AppleEvent descriptors and back (unpacking).
Within Python the AppleEvent descriptor is handled by Python objects
of built-in type <tt class="class">AEDesc</tt>, defined in module <tt class="module"><a href="module-Carbon.AE.html">Carbon.AE</a></tt>.

<P>
The <tt class="module">aepack</tt> module defines the following functions:

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-157' class="function">pack</tt></b>(</nobr></td>
  <td><var>x</var><big>[</big><var>, forcetype</var><big>]</big>)</td></tr></table></dt>
<dd>
Returns an <tt class="class">AEDesc</tt> object  containing a conversion of Python
value x. If <var>forcetype</var> is provided it specifies the descriptor
type of the result. Otherwise, a default mapping of Python types to
Apple Event descriptor types is used, as follows:

<P>
<table border align="center" style="border-collapse: collapse">
  <thead>
    <tr class="tableheader">
      <th align="left"><b>Python type</b>&nbsp;</th>
      <th align="left"><b>descriptor type</b>&nbsp;</th>
      </tr>
    </thead>
  <tbody valign="baseline">
    <tr><td align="left" valign="baseline"><tt class="class">FSSpec</tt></td>
        <td align="left">typeFSS</td>
    <tr><td align="left" valign="baseline"><tt class="class">FSRef</tt></td>
        <td align="left">typeFSRef</td>
    <tr><td align="left" valign="baseline"><tt class="class">Alias</tt></td>
        <td align="left">typeAlias</td>
    <tr><td align="left" valign="baseline">integer</td>
        <td align="left">typeLong (32 bit integer)</td>
    <tr><td align="left" valign="baseline">float</td>
        <td align="left">typeFloat (64 bit floating point)</td>
    <tr><td align="left" valign="baseline">string</td>
        <td align="left">typeText</td>
    <tr><td align="left" valign="baseline">unicode</td>
        <td align="left">typeUnicodeText</td>
    <tr><td align="left" valign="baseline">list</td>
        <td align="left">typeAEList</td>
    <tr><td align="left" valign="baseline">dictionary</td>
        <td align="left">typeAERecord</td>
    <tr><td align="left" valign="baseline">instance</td>
        <td align="left"><i>see below</i></td></tbody>
</table>  

<P>
If <var>x</var> is a Python instance then this function attempts to call an
<tt class="method">__aepack__()</tt> method.  This method should return an
<tt class="class">AEDesc</tt> object.

<P>
If the conversion <var>x</var> is not defined above, this function returns
the Python string representation of a value (the repr() function)
encoded as a text descriptor.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-158' class="function">unpack</tt></b>(</nobr></td>
  <td><var>x</var><big>[</big><var>, formodulename</var><big>]</big>)</td></tr></table></dt>
<dd>
  <var>x</var> must be an object of type <tt class="class">AEDesc</tt>. This function
  returns a Python object representation of the data in the Apple
  Event descriptor <var>x</var>. Simple AppleEvent data types (integer,
  text, float) are returned as their obvious Python counterparts.
  Apple Event lists are returned as Python lists, and the list
  elements are recursively unpacked.  Object references
  (ex. <code>line 3 of document 1</code>) are returned as instances of
  <tt class="class">aetypes.ObjectSpecifier</tt>, unless <code>formodulename</code>
  is specified.  AppleEvent descriptors with
  descriptor type typeFSS are returned as <tt class="class">FSSpec</tt>
  objects.  AppleEvent record descriptors are returned as Python
  dictionaries, with 4-character string keys and elements recursively
  unpacked.

<P>
The optional <code>formodulename</code> argument is used by the stub packages
  generated by <tt class="module">gensuitemodule</tt>, and ensures that the OSA classes
  for object specifiers are looked up in the correct module. This ensures
  that if, say, the Finder returns an object specifier for a window
  you get an instance of <code>Finder.Window</code> and not a generic
  <code>aetypes.Window</code>. The former knows about all the properties
  and elements a window has in the Finder, while the latter knows
  no such things.
</dl>

<P>
<div class="seealso">
  <p class="heading"><b>See Also:</b></p>

  <dl compact class="seemodule">
    <dt>Module <b><tt class="module"><a href="module-Carbon.AE.html">Carbon.AE</a></tt>:</b>
    <dd>Built-in access to Apple Event Manager routines.
  </dl>
  <dl compact class="seemodule">
    <dt>Module <b><tt class="module"><a href="module-aetypes.html">aetypes</a></tt>:</b>
    <dd>Python definitions of codes for Apple Event
                      descriptor types.
  </dl>
  <dl compact class="seetitle">
    <dt><em class="citetitle"><a href="http://developer.apple.com/techpubs/mac/IAC/IAC-2.html"
        >
            Inside Macintosh: Interapplication
            Communication</a></em></dt>
    <dd>Information about inter-process
            communications on the Macintosh.</dd>
  </dl>
</div>

<DIV CLASS="navigation">
<div class='online-navigation'><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="3.2 aetools  " 
  rel="prev" title="3.2 aetools  " 
  href="module-aetools.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="3. MacPython OSA Modules" 
  rel="parent" title="3. MacPython OSA Modules" 
  href="scripting.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="3.4 aetypes  " 
  rel="next" title="3.4 aetypes  " 
  href="module-aetypes.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Macintosh Library Modules</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents" 
  rel="contents" title="Table of Contents" 
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index" 
  rel="index" title="Index" 
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-aetools.html">3.2 aetools  </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="scripting.html">3. MacPython OSA Modules</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-aetypes.html">3.4 aetypes  </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.3.4, documentation updated on May 20, 2004.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>