blob: 4548492d3661e58fb320ffd997324bede64007d8 [file] [log] [blame]
Fred Drake3a0351c1998-04-04 07:23:21 +00001\section{Standard Module \module{ic}}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00002\declaremodule{builtin}{ic}
3
4\modulesynopsis{None}
5
Guido van Rossume229d861997-08-18 15:14:26 +00006
Guido van Rossume229d861997-08-18 15:14:26 +00007
Fred Drakeebce3701998-03-14 22:22:14 +00008This module provides access to Macintosh Internet Config package,
Guido van Rossume229d861997-08-18 15:14:26 +00009which stores preferences for Internet programs such as mail address,
10default homepage, etc. Also, Internet Config contains an elaborate set
11of mappings from Macintosh creator/type codes to foreign filename
12extensions plus information on how to transfer files (binary, ascii,
Fred Drakeebce3701998-03-14 22:22:14 +000013etc).
Guido van Rossume229d861997-08-18 15:14:26 +000014
Fred Drakeebce3701998-03-14 22:22:14 +000015There is a low-level companion module
16\module{icglue}\refbimodindex{icglue} which provides the basic
17Internet Config access functionality. This low-level module is not
Guido van Rossume229d861997-08-18 15:14:26 +000018documented, but the docstrings of the routines document the parameters
Fred Drakeebce3701998-03-14 22:22:14 +000019and the routine names are the same as for the Pascal or \C{} API to
20Internet Config, so the standard IC programmers' documentation can be
Guido van Rossume229d861997-08-18 15:14:26 +000021used if this module is needed.
22
Fred Drakeebce3701998-03-14 22:22:14 +000023The \module{ic} module defines the \exception{error} exception and
24symbolic names for all error codes Internet Config can produce; see
25the source for details.
Guido van Rossume229d861997-08-18 15:14:26 +000026
Fred Drakeebce3701998-03-14 22:22:14 +000027\begin{excdesc}{error}
28Exception raised on errors in the \module{ic} module.
29\end{excdesc}
Guido van Rossume229d861997-08-18 15:14:26 +000030
Fred Drakeebce3701998-03-14 22:22:14 +000031
Fred Drake5ab55031998-04-07 22:01:33 +000032The \module{ic} module defines the following class and function:
Fred Drakeebce3701998-03-14 22:22:14 +000033
Fred Drake5ab55031998-04-07 22:01:33 +000034\begin{classdesc}{IC}{\optional{signature\optional{, ic}}}
Fred Drake41788db1998-04-04 06:23:02 +000035Create an internet config object. The signature is a 4-character creator
Guido van Rossume229d861997-08-18 15:14:26 +000036code of the current application (default \code{'Pyth'}) which may
37influence some of ICs settings. The optional \var{ic} argument is a
Fred Drakeebce3701998-03-14 22:22:14 +000038low-level \code{icglue.icinstance} created beforehand, this may be
39useful if you want to get preferences from a different config file,
40etc.
Fred Drake5ab55031998-04-07 22:01:33 +000041\end{classdesc}
Guido van Rossume229d861997-08-18 15:14:26 +000042
Fred Drakeebce3701998-03-14 22:22:14 +000043\begin{funcdesc}{launchurl}{url\optional{, hint}}
44\funcline{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
45\funcline{mapfile}{file}
46\funcline{maptypecreator}{type, creator\optional{, filename}}
47\funcline{settypecreator}{file}
Guido van Rossume229d861997-08-18 15:14:26 +000048These functions are ``shortcuts'' to the methods of the same name,
49described below.
50\end{funcdesc}
51
52
Fred Drake5ab55031998-04-07 22:01:33 +000053\subsection{IC Objects}
Guido van Rossume229d861997-08-18 15:14:26 +000054
Fred Drake5ab55031998-04-07 22:01:33 +000055\class{IC} objects have a mapping interface, hence to obtain the mail
56address you simply get \code{\var{ic}['MailAddress']}. Assignment also
57works, and changes the option in the configuration file.
Guido van Rossume229d861997-08-18 15:14:26 +000058
59The module knows about various datatypes, and converts the internal IC
Fred Drake5ab55031998-04-07 22:01:33 +000060representation to a ``logical'' Python data structure. Running the
Fred Drakeebce3701998-03-14 22:22:14 +000061\module{ic} module standalone will run a test program that lists all
Guido van Rossume229d861997-08-18 15:14:26 +000062keys and values in your IC database, this will have to server as
63documentation.
64
65If the module does not know how to represent the data it returns an
Fred Drakeebce3701998-03-14 22:22:14 +000066instance of the \code{ICOpaqueData} type, with the raw data in its
Fred Drake41788db1998-04-04 06:23:02 +000067\member{data} attribute. Objects of this type are also acceptable values
Guido van Rossume229d861997-08-18 15:14:26 +000068for assignment.
69
Fred Drake5ab55031998-04-07 22:01:33 +000070Besides the dictionary interface, \class{IC} objects have the
71following methods:
Guido van Rossume229d861997-08-18 15:14:26 +000072
Guido van Rossume229d861997-08-18 15:14:26 +000073
Fred Drake5ab55031998-04-07 22:01:33 +000074\begin{methoddesc}{launchurl}{url\optional{, hint}}
Guido van Rossume229d861997-08-18 15:14:26 +000075Parse the given URL, lauch the correct application and pass it the
76URL. The optional \var{hint} can be a scheme name such as
Fred Drakeebce3701998-03-14 22:22:14 +000077\code{'mailto:'}, in which case incomplete URLs are completed with this
78scheme. If \var{hint} is not provided, incomplete URLs are invalid.
Fred Drake5ab55031998-04-07 22:01:33 +000079\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +000080
Fred Drake5ab55031998-04-07 22:01:33 +000081\begin{methoddesc}{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
Guido van Rossume229d861997-08-18 15:14:26 +000082Find an URL somewhere in \var{data} and return start position, end
83position and the URL. The optional \var{start} and \var{end} can be
84used to limit the search, so for instance if a user clicks in a long
85textfield you can pass the whole textfield and the click-position in
86\var{start} and this routine will return the whole URL in which the
Fred Drake41788db1998-04-04 06:23:02 +000087user clicked. As above, \var{hint} is an optional scheme used to
88complete incomplete URLs.
Fred Drake5ab55031998-04-07 22:01:33 +000089\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +000090
Fred Drake5ab55031998-04-07 22:01:33 +000091\begin{methoddesc}{mapfile}{file}
Guido van Rossume229d861997-08-18 15:14:26 +000092Return the mapping entry for the given \var{file}, which can be passed
Fred Drake41788db1998-04-04 06:23:02 +000093as either a filename or an \function{macfs.FSSpec()} result, and which
94need not exist.
Guido van Rossume229d861997-08-18 15:14:26 +000095
Fred Drake671fe9d1997-12-29 18:53:31 +000096The mapping entry is returned as a tuple \code{(}\var{version},
97\var{type}, \var{creator}, \var{postcreator}, \var{flags},
98\var{extension}, \var{appname}, \var{postappname}, \var{mimetype},
99\var{entryname}\code{)}, where \var{version} is the entry version
Fred Drake41788db1998-04-04 06:23:02 +0000100number, \var{type} is the 4-character filetype, \var{creator} is the
1014-character creator type, \var{postcreator} is the 4-character creator
102code of an
Guido van Rossume229d861997-08-18 15:14:26 +0000103optional application to post-process the file after downloading,
104\var{flags} are various bits specifying whether to transfer in binary
105or ascii and such, \var{extension} is the filename extension for this
106file type, \var{appname} is the printable name of the application to
107which this file belongs, \var{postappname} is the name of the
108postprocessing application, \var{mimetype} is the MIME type of this
109file and \var{entryname} is the name of this entry.
Fred Drake5ab55031998-04-07 22:01:33 +0000110\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +0000111
Fred Drake5ab55031998-04-07 22:01:33 +0000112\begin{methoddesc}{maptypecreator}{type, creator\optional{, filename}}
Fred Drake41788db1998-04-04 06:23:02 +0000113Return the mapping entry for files with given 4-character \var{type} and
Guido van Rossume229d861997-08-18 15:14:26 +0000114\var{creator} codes. The optional \var{filename} may be specified to
115further help finding the correct entry (if the creator code is
116\code{'????'}, for instance).
117
118The mapping entry is returned in the same format as for \var{mapfile}.
Fred Drake5ab55031998-04-07 22:01:33 +0000119\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +0000120
Fred Drake5ab55031998-04-07 22:01:33 +0000121\begin{methoddesc}{settypecreator}{file}
Guido van Rossume229d861997-08-18 15:14:26 +0000122Given an existing \var{file}, specified either as a filename or as an
Fred Drake41788db1998-04-04 06:23:02 +0000123\function{macfs.FSSpec()} result, set its creator and type correctly based
Fred Drakeebce3701998-03-14 22:22:14 +0000124on its extension. The finder is told about the change, so the finder
125icon will be updated quickly.
Fred Drake5ab55031998-04-07 22:01:33 +0000126\end{methoddesc}