home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
python
/
pyhtmldoc
/
b
/
bastion
next >
Wrap
Text File
|
1996-11-14
|
2KB
|
33 lines
<TITLE>Bastion -- Python library reference</TITLE>
Prev: <A HREF="../r/rexec" TYPE="Prev">rexec</A>
Up: <A HREF="../r/restricted_execution" TYPE="Up">Restricted Execution</A>
Top: <A HREF="../t/top" TYPE="Top">Top</A>
<H1>11.2. Standard Module <CODE>Bastion</CODE></H1>
According to the dictionary, a bastion is ``a fortified area or
position'', or ``something that is considered a stronghold.'' It's a
suitable name for this module, which provides a way to forbid access
to certain attributes of an object. It must always be used with the
<CODE>rexec</CODE> module, in order to allow restricted-mode programs access
to certain safe attributes of an object, while denying access to
other, unsafe attributes.
<P>
<DL><DT><B>Bastion</B> (<VAR>object</VAR>[, <VAR>filter</VAR>, <VAR>name</VAR>, <VAR>class</VAR>]) -- function of module Bastion<DD>
Protect the class instance <VAR>object</VAR>, returning a bastion for the
object. Any attempt to access one of the object's attributes will
have to be approved by the <VAR>filter</VAR> function; if the access is
denied an AttributeError exception will be raised.
<P>
If present, <VAR>filter</VAR> must be a function that accepts a string
containing an attribute name, and returns true if access to that
attribute will be permitted; if <VAR>filter</VAR> returns false, the access
is denied. The default filter denies access to any function beginning
with an underscore (<CODE>_</CODE>). The bastion's string representation
will be <CODE><Bastion for <VAR>name</VAR>></CODE> if a value for
<VAR>name</VAR> is provided; otherwise, <CODE>repr(<VAR>object</VAR>)</CODE> will be used.
<P>
<VAR>class</VAR>, if present, would be a subclass of <CODE>BastionClass</CODE>;
see the code in <FILE>bastion.py</FILE> for the details. Overriding the
default <CODE>BastionClass</CODE> will rarely be required.
<P>
</DL>