How do I limit access to objects in Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tommytrojan

    #1

    How do I limit access to objects in Python?

    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.

    Thanks,
    Thomas

  • Diez B. Roggisch

    #2
    Re: How do I limit access to objects in Python?

    Tommytrojan schrieb:[color=blue]
    > 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.[/color]

    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

    Comment

    Working...