How do I limit access to objects in Python?

Diez B. Roggisch deets at nospam.web.de
Tue Jun 27 03:54:02 EDT 2006


Tommytrojan schrieb:
> Hi,
> 
> I have an application that embeds the Python interpreter. My users have 
> access to the interpreter through a console like window and they can run 
> Python scripts. For my application I use some Python modules (say module 
> Restricted) that I don't want to give my users access to. However, the 
> modules that I make public to my users and that I want my users to be 
> able to use themselves use the Restricted module. Any suggestions on how 
> to solve this? I was thinking of instantiating a separate interpreter 
> but I don't think this will solve my problem.

I don't think that is possible - how is one to distinguish your code 
from the code written by a user that calls one method in the restricted 
module?

What you _can_ do is to spawn an interpreter, and expose the allowed 
objects via Pyro.


The question is though: why cripple your users? If someone could reach 
an otherwise unreachable goal why do yoou hinder him? What is the 
reasoning behind that?

Diez



More information about the Python-list mailing list