'Method called when open() is called in the restricted environment.
The arguments are identical to those of the open() function, and a
file object (or a class instance compatible with file objects)
should be returned.  RExec\'s default behaviour is allow opening
any file for reading, but forbidding any attempt to write a file.
This method is implicitly called by code executing in the
restricted environment.  Overriding this method in a subclass is
used to change the policies enforced by a restricted environment.'

def r_open(self, file, mode='r', buf=(-1)):

    mode = str(mode)
    if (mode not in ('r', 'rb')):
        raise IOError, "can't    open    files    for    writing    in    restricted    mode"
    return open(file, mode, buf)
