blob: 7cd0557205b2d2cd3be1f81f042a66bc0ef08e6f [file] [log] [blame]
Guido van Rossume229d861997-08-18 15:14:26 +00001\section{Standard Module \sectcode{ic}}
Fred Drake12918af1998-02-18 15:10:24 +00002\label{module-ic}
Guido van Rossume229d861997-08-18 15:14:26 +00003\bimodindex{ic}
4
Guido van Rossume229d861997-08-18 15:14:26 +00005
Fred Drakeebce3701998-03-14 22:22:14 +00006This module provides access to Macintosh Internet Config package,
Guido van Rossume229d861997-08-18 15:14:26 +00007which stores preferences for Internet programs such as mail address,
8default homepage, etc. Also, Internet Config contains an elaborate set
9of mappings from Macintosh creator/type codes to foreign filename
10extensions plus information on how to transfer files (binary, ascii,
Fred Drakeebce3701998-03-14 22:22:14 +000011etc).
Guido van Rossume229d861997-08-18 15:14:26 +000012
Fred Drakeebce3701998-03-14 22:22:14 +000013There is a low-level companion module
14\module{icglue}\refbimodindex{icglue} which provides the basic
15Internet Config access functionality. This low-level module is not
Guido van Rossume229d861997-08-18 15:14:26 +000016documented, but the docstrings of the routines document the parameters
Fred Drakeebce3701998-03-14 22:22:14 +000017and the routine names are the same as for the Pascal or \C{} API to
18Internet Config, so the standard IC programmers' documentation can be
Guido van Rossume229d861997-08-18 15:14:26 +000019used if this module is needed.
20
Fred Drakeebce3701998-03-14 22:22:14 +000021The \module{ic} module defines the \exception{error} exception and
22symbolic names for all error codes Internet Config can produce; see
23the source for details.
Guido van Rossume229d861997-08-18 15:14:26 +000024
Fred Drakeebce3701998-03-14 22:22:14 +000025\begin{excdesc}{error}
26Exception raised on errors in the \module{ic} module.
27\end{excdesc}
Guido van Rossume229d861997-08-18 15:14:26 +000028
Fred Drakeebce3701998-03-14 22:22:14 +000029
30The \module{ic} module defines the following functions:
31
32\begin{funcdesc}{IC}{\optional{signature\optional{, ic}}}
Fred Drake41788db1998-04-04 06:23:02 +000033Create an internet config object. The signature is a 4-character creator
Guido van Rossume229d861997-08-18 15:14:26 +000034code of the current application (default \code{'Pyth'}) which may
35influence some of ICs settings. The optional \var{ic} argument is a
Fred Drakeebce3701998-03-14 22:22:14 +000036low-level \code{icglue.icinstance} created beforehand, this may be
37useful if you want to get preferences from a different config file,
38etc.
Guido van Rossume229d861997-08-18 15:14:26 +000039\end{funcdesc}
40
Fred Drakeebce3701998-03-14 22:22:14 +000041\begin{funcdesc}{launchurl}{url\optional{, hint}}
42\funcline{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
43\funcline{mapfile}{file}
44\funcline{maptypecreator}{type, creator\optional{, filename}}
45\funcline{settypecreator}{file}
Guido van Rossume229d861997-08-18 15:14:26 +000046These functions are ``shortcuts'' to the methods of the same name,
47described below.
48\end{funcdesc}
49
50
51\subsection{IC objects}
52
53IC objects have a mapping interface, hence to obtain the mail address
Fred Drakeebce3701998-03-14 22:22:14 +000054you simply get \code{\var{ic}['MailAddress']}. Assignment also works,
55and changes the option in the configuration file.
Guido van Rossume229d861997-08-18 15:14:26 +000056
57The module knows about various datatypes, and converts the internal IC
Fred Drake61885921998-04-03 07:16:46 +000058representation to a ``logical'' Python datastructure. Running the
Fred Drakeebce3701998-03-14 22:22:14 +000059\module{ic} module standalone will run a test program that lists all
Guido van Rossume229d861997-08-18 15:14:26 +000060keys and values in your IC database, this will have to server as
61documentation.
62
63If the module does not know how to represent the data it returns an
Fred Drakeebce3701998-03-14 22:22:14 +000064instance of the \code{ICOpaqueData} type, with the raw data in its
Fred Drake41788db1998-04-04 06:23:02 +000065\member{data} attribute. Objects of this type are also acceptable values
Guido van Rossume229d861997-08-18 15:14:26 +000066for assignment.
67
68Besides the dictionary interface IC objects have the following methods:
69
Fred Drakeebce3701998-03-14 22:22:14 +000070\setindexsubitem{(IC attribute)}
Guido van Rossume229d861997-08-18 15:14:26 +000071
Fred Drakeebce3701998-03-14 22:22:14 +000072\begin{funcdesc}{launchurl}{url\optional{, hint}}
Guido van Rossume229d861997-08-18 15:14:26 +000073Parse the given URL, lauch the correct application and pass it the
74URL. The optional \var{hint} can be a scheme name such as
Fred Drakeebce3701998-03-14 22:22:14 +000075\code{'mailto:'}, in which case incomplete URLs are completed with this
76scheme. If \var{hint} is not provided, incomplete URLs are invalid.
Guido van Rossume229d861997-08-18 15:14:26 +000077\end{funcdesc}
78
Fred Drakeebce3701998-03-14 22:22:14 +000079\begin{funcdesc}{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
Guido van Rossume229d861997-08-18 15:14:26 +000080Find an URL somewhere in \var{data} and return start position, end
81position and the URL. The optional \var{start} and \var{end} can be
82used to limit the search, so for instance if a user clicks in a long
83textfield you can pass the whole textfield and the click-position in
84\var{start} and this routine will return the whole URL in which the
Fred Drake41788db1998-04-04 06:23:02 +000085user clicked. As above, \var{hint} is an optional scheme used to
86complete incomplete URLs.
Guido van Rossume229d861997-08-18 15:14:26 +000087\end{funcdesc}
88
89\begin{funcdesc}{mapfile}{file}
90Return the mapping entry for the given \var{file}, which can be passed
Fred Drake41788db1998-04-04 06:23:02 +000091as either a filename or an \function{macfs.FSSpec()} result, and which
92need not exist.
Guido van Rossume229d861997-08-18 15:14:26 +000093
Fred Drake671fe9d1997-12-29 18:53:31 +000094The mapping entry is returned as a tuple \code{(}\var{version},
95\var{type}, \var{creator}, \var{postcreator}, \var{flags},
96\var{extension}, \var{appname}, \var{postappname}, \var{mimetype},
97\var{entryname}\code{)}, where \var{version} is the entry version
Fred Drake41788db1998-04-04 06:23:02 +000098number, \var{type} is the 4-character filetype, \var{creator} is the
994-character creator type, \var{postcreator} is the 4-character creator
100code of an
Guido van Rossume229d861997-08-18 15:14:26 +0000101optional application to post-process the file after downloading,
102\var{flags} are various bits specifying whether to transfer in binary
103or ascii and such, \var{extension} is the filename extension for this
104file type, \var{appname} is the printable name of the application to
105which this file belongs, \var{postappname} is the name of the
106postprocessing application, \var{mimetype} is the MIME type of this
107file and \var{entryname} is the name of this entry.
108\end{funcdesc}
109
Fred Drakeebce3701998-03-14 22:22:14 +0000110\begin{funcdesc}{maptypecreator}{type, creator\optional{, filename}}
Fred Drake41788db1998-04-04 06:23:02 +0000111Return the mapping entry for files with given 4-character \var{type} and
Guido van Rossume229d861997-08-18 15:14:26 +0000112\var{creator} codes. The optional \var{filename} may be specified to
113further help finding the correct entry (if the creator code is
114\code{'????'}, for instance).
115
116The mapping entry is returned in the same format as for \var{mapfile}.
117\end{funcdesc}
118
119\begin{funcdesc}{settypecreator}{file}
120Given an existing \var{file}, specified either as a filename or as an
Fred Drake41788db1998-04-04 06:23:02 +0000121\function{macfs.FSSpec()} result, set its creator and type correctly based
Fred Drakeebce3701998-03-14 22:22:14 +0000122on its extension. The finder is told about the change, so the finder
123icon will be updated quickly.
Guido van Rossume229d861997-08-18 15:14:26 +0000124\end{funcdesc}