[IPython-dev] IPython authentication
Tue Feb 5 04:36:11 CST 2013
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.
2013/2/5, MinRK <email@example.com>:
> On Mon, Feb 4, 2013 at 9:44 PM, Wojciech Daniło
>> Benjamin thank you very much for yours answer! I'm very happy that all
>> things are implemented - I'm starting to test these things out :)
>> If I could I owuld ask you additional 2, a little more precious
>> 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
>> (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
>> 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
>> 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
>> ;) )
> I would recommend trying to use the existing functionality as best you can.
> In general, you would use:
> publisher = get_ipython().display_pub
> publisher.publish("myapp", display_data)
> That should let you publish fairly arbitrary data to the clients.
>> Thank you once again!
>> 2013/2/5 MinRK <firstname.lastname@example.org>
>>> On Mon, Feb 4, 2013 at 9:08 PM, Wojciech Daniło <
>>> email@example.com> wrote:
>>>> 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
>>>> 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
>>>> network) and execute Python code - everything so far is provided by
>>>> 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
>>>> code - lets say "draw line", I want this line t show in the second user
>>>> 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
>>> object, so at the very least every frontend (aka client aka user
>>> 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.
>>> IPython-dev mailing list
>> IPython-dev mailing list
More information about the IPython-dev