[IPython-dev] IPython authentication

MinRK benjaminrk@gmail....
Mon Feb 4 23:28:44 CST 2013


On Mon, Feb 4, 2013 at 9:08 PM, Wojciech Daniło
<wojtek.danilo.ml@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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20130204/d3517ed8/attachment.html 


More information about the IPython-dev mailing list