[IPython-dev] IPython authentication

MinRK benjaminrk at gmail.com
Tue Feb 5 12:33:02 EST 2013


On Tue, Feb 5, 2013 at 2:36 AM, Wojciech Daniło
<wojtek.danilo.ml at gmail.com>wrote:

> Thank you! All the informations provided by you are very useful for me.
>
> Would you please tell me one more thing? Is there any implemented
> mechanism for handling such situation, that each user will have custom
> "variable namespace" with several variables shared.
> I want simply  keep each users locals variables separate, so If A user
> will type "a=5" and B user will type "a=6" these variables will not
> overlap. But if user A will type "batch.x=5", then user B is able to
> access this varbiale, since "batch" variable is shared between them.


> I know this is very special case and probably there is nothing
> implemented which is able to handle it, but maybe you'll be able to
> give me last portion of hints how to start with it.
>
>

No, this is not something IPython provides.  If you were to do this, you
would need to subclass the Kernel,
and override execute_request to change the shell.user_ns based on the
client that submits each request.



>
> 2013/2/5, MinRK <benjaminrk at gmail.com>:
> > On Mon, Feb 4, 2013 at 9:44 PM, Wojciech Daniło
> > <wojtek.danilo.ml at gmail.com>wrote:
> >
> >> Benjamin thank you very much for yours answer! I'm very happy that all
> >> the
> >> things are implemented - I'm starting to test these things out :)
> >>
> >> If I could I owuld ask you additional 2, a little more precious
> >> questions:
> >> 1) Lets concider we have kernel K and clients A and B. If client A
> >> executes something on K, I would like K to send notification about it to
> >> B
> >> (broadcast to clients) - I think youre talking about something like that
> >> (or am I wrong?).
> >>
> >
> > Yes, this is the `pyin` message. It is sent to all clients on the iopub
> > channel when an execute_request begins (prior to evaluating that
> request).
> >
> >
> >> 2) Additional when A or B executes a command on K it will run some
> >> functions from my batch python module. Is it possible that these
> >> functions
> >> will broadcast some customized messages to client with the functionality
> >> provided by Kernel?
> >>
> >
> > Yes, if you modify the kernel.  You might be able to get away with just
> > registering a `post_execute_hook` in IPython.
> >
> >
> >> So basically is it possible to send to Kernel and from Kernel to clients
> >> customized messages with custom fields etc (extend the handling
> >> mechanizm)
> >> or should I implement this next to the IPython communication mechanism
> (I
> >> do not want to implement that next to it, because that is a little bit
> >> ugly
> >> ;) )
> >>
> >
> > I would recommend trying to use the existing functionality as best you
> can.
> >  In general, you would use:
> >
> > publisher = get_ipython().display_pub
> >
> > and
> >
> > publisher.publish("myapp", display_data)
> >
> > That should let you publish fairly arbitrary data to the clients.
> >
> >
> >
> >>
> >> Thank you once again!
> >>
> >> 2013/2/5 MinRK <benjaminrk at gmail.com>
> >>
> >>>
> >>>
> >>> On Mon, Feb 4, 2013 at 9:08 PM, Wojciech Daniło <
> >>> wojtek.danilo.ml at gmail.com> wrote:
> >>>
> >>>> Hi!
> >>>> I'm new to IPython, but this project seems like a very good
> >>>> "boilerplate" for my custom project. I've read a lot of docs and
> looked
> >>>> at
> >>>> the source code and I want to ask you if something I want to do with
> >>>> IPython is possible.
> >>>>
> >>>> I want to run a IPython Kernel on a machine. It will execute my batch
> >>>> program. I want users to be able to connect to this kernel (locally or
> >>>> over
> >>>> network) and execute Python code - everything so far is provided by
> >>>> IPython
> >>>> i think.
> >>>> The problem is, I want to know WHICH user executed the code, because I
> >>>> want to make something like collaboration model - If one user executes
> >>>> a
> >>>> code - lets say "draw line", I want this line t show in the second
> user
> >>>> GUI
> >>>> with a tooltip, which user executed it.
> >>>>
> >>>> Is it somehow possible? Could you give me any hints how to do it?
> >>>>
> >>>
> >>> Messages have a 'session' key, which is unique, and a username in the
> >>> header (generally the unix username).  These are attributes of the
> >>> Session
> >>> object, so at the very least every frontend (aka client aka user
> >>> session)
> >>> has a unique ID.  The header of each request is attached as the
> >>> 'parent_header' of replies and side effects of the request.  Among
> these
> >>> side effects (of execute_requests) are:
> >>>
> >>> pyin: the Python code just run
> >>> display_data: display side effects
> >>> stream: stdout/stderr
> >>>
> >>> And these come to all frontends on the iopub channel.
> >>>
> >>> So let's say you have two frontends attached to the Kernel.  When a
> >>> 'pyin' message comes in on the iopub channel, and you check it, you can
> >>> trigger an event based on the content and parent_header, such as
> "client
> >>> [FOO] just ran this code: etc.".
> >>>
> >>> If you want to draw the display *results* of the execution, they will
> be
> >>> `display_data` messages on the same channel, and you can associate them
> >>> with their source in the same way.
> >>>
> >>>  That should be all you need, I think.
> >>>
> >>> -MinRK
> >>>
> >>> _______________________________________________
> >>> IPython-dev mailing list
> >>> IPython-dev at scipy.org
> >>> http://mail.scipy.org/mailman/listinfo/ipython-dev
> >>>
> >>>
> >>
> >> _______________________________________________
> >> IPython-dev mailing list
> >> IPython-dev at scipy.org
> >> http://mail.scipy.org/mailman/listinfo/ipython-dev
> >>
> >>
> >
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130205/ec523a53/attachment.html>


More information about the IPython-dev mailing list