Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / module-Bastion.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="module-rexec.html" />
13<link rel="parent" href="restricted.html" />
14<link rel="next" href="language.html" />
15<meta name='aesop' content='information' />
16<title>17.2 Bastion -- Restricting access to objects</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="17.1.3 An example"
24 href="node763.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="17. Restricted Execution"
27 href="restricted.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="18. Python Language Services"
30 href="language.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="node763.html">17.1.3 An example</A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="restricted.html">17. Restricted Execution</A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="language.html">18. Python Language Services</A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H1><A NAME="SECTION0019200000000000000000">
5517.2 <tt class="module">Bastion</tt> --
56 Restricting access to objects</A>
57</H1>
58
59<P>
60<A NAME="module-Bastion"></A>
61
62<span class="versionnote">Changed in version 2.3:
63Disabled module.</span>
64
65<P>
66<div class="warning"><b class="label">Warning:</b>
67
68 The documentation has been left in place to help in reading old code
69 that uses the module.
70</div>
71
72<P>
73According to the dictionary, a bastion is ``a fortified area or
74position'', or ``something that is considered a stronghold.'' It's a
75suitable name for this module, which provides a way to forbid access
76to certain attributes of an object. It must always be used with the
77<tt class="module"><a href="module-rexec.html">rexec</a></tt> module, in order to allow restricted-mode programs
78access to certain safe attributes of an object, while denying access
79to other, unsafe attributes.
80
81<P>
82<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
83 <td><nobr><b><tt id='l2h-4934' xml:id='l2h-4934' class="function">Bastion</tt></b>(</nobr></td>
84 <td><var>object</var><big>[</big><var>, filter</var><big>[</big><var>,
85 name</var><big>[</big><var>, class</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
86<dd>
87Protect the object <var>object</var>, returning a bastion for the
88object. Any attempt to access one of the object's attributes will
89have to be approved by the <var>filter</var> function; if the access is
90denied an <tt class="exception">AttributeError</tt> exception will be raised.
91
92<P>
93If present, <var>filter</var> must be a function that accepts a string
94containing an attribute name, and returns true if access to that
95attribute will be permitted; if <var>filter</var> returns false, the access
96is denied. The default filter denies access to any function beginning
97with an underscore ("<tt class="character">_</tt>"). The bastion's string representation
98will be "<tt class="samp">&lt;Bastion for <var>name</var>&gt;</tt>" if a value for
99<var>name</var> is provided; otherwise, "<tt class="samp">repr(<var>object</var>)</tt>" will be
100used.
101
102<P>
103<var>class</var>, if present, should be a subclass of <tt class="class">BastionClass</tt>;
104see the code in <span class="file">bastion.py</span> for the details. Overriding the
105default <tt class="class">BastionClass</tt> will rarely be required.
106</dl>
107
108<P>
109<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
110 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-4935' xml:id='l2h-4935' class="class">BastionClass</tt></b>(</nobr></td>
111 <td><var>getfunc, name</var>)</td></tr></table></dt>
112<dd>
113Class which actually implements bastion objects. This is the default
114class used by <tt class="function">Bastion()</tt>. The <var>getfunc</var> parameter is a
115function which returns the value of an attribute which should be
116exposed to the restricted execution environment when called with the
117name of the attribute as the only parameter. <var>name</var> is used to
118construct the <tt class="function">repr()</tt> of the <tt class="class">BastionClass</tt> instance.
119</dl>
120
121<P>
122
123<DIV CLASS="navigation">
124<div class='online-navigation'>
125<p></p><hr />
126<table align="center" width="100%" cellpadding="0" cellspacing="2">
127<tr>
128<td class='online-navigation'><a rel="prev" title="17.1.3 An example"
129 href="node763.html"><img src='../icons/previous.png'
130 border='0' height='32' alt='Previous Page' width='32' /></A></td>
131<td class='online-navigation'><a rel="parent" title="17. Restricted Execution"
132 href="restricted.html"><img src='../icons/up.png'
133 border='0' height='32' alt='Up One Level' width='32' /></A></td>
134<td class='online-navigation'><a rel="next" title="18. Python Language Services"
135 href="language.html"><img src='../icons/next.png'
136 border='0' height='32' alt='Next Page' width='32' /></A></td>
137<td align="center" width="100%">Python Library Reference</td>
138<td class='online-navigation'><a rel="contents" title="Table of Contents"
139 href="contents.html"><img src='../icons/contents.png'
140 border='0' height='32' alt='Contents' width='32' /></A></td>
141<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
142 border='0' height='32' alt='Module Index' width='32' /></a></td>
143<td class='online-navigation'><a rel="index" title="Index"
144 href="genindex.html"><img src='../icons/index.png'
145 border='0' height='32' alt='Index' width='32' /></A></td>
146</tr></table>
147<div class='online-navigation'>
148<b class="navlabel">Previous:</b>
149<a class="sectref" rel="prev" href="node763.html">17.1.3 An example</A>
150<b class="navlabel">Up:</b>
151<a class="sectref" rel="parent" href="restricted.html">17. Restricted Execution</A>
152<b class="navlabel">Next:</b>
153<a class="sectref" rel="next" href="language.html">18. Python Language Services</A>
154</div>
155</div>
156<hr />
157<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
158</DIV>
159<!--End of Navigation Panel-->
160<ADDRESS>
161See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
162</ADDRESS>
163</BODY>
164</HTML>