<br><br><div class="gmail_quote">On Tue, Feb 5, 2013 at 2:36 AM, Wojciech Daniło <span dir="ltr"><<a href="mailto:wojtek.danilo.ml@gmail.com" target="_blank">wojtek.danilo.ml@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Thank you! All the informations provided by you are very useful for me.<br>
<br>
Would you please tell me one more thing? Is there any implemented<br>
mechanism for handling such situation, that each user will have custom<br>
"variable namespace" with several variables shared.<br>
I want simply  keep each users locals variables separate, so If A user<br>
will type "a=5" and B user will type "a=6" these variables will not<br>
overlap. But if user A will type "batch.x=5", then user B is able to<br>
access this varbiale, since "batch" variable is shared between them. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I know this is very special case and probably there is nothing<br>
implemented which is able to handle it, but maybe you'll be able to<br>
give me last portion of hints how to start with it.<br>
<br></blockquote><div><br></div><div><div><br class="Apple-interchange-newline">No, this is not something IPython provides.  If you were to do this, you would need to subclass the Kernel,</div><div>and override execute_request to change the shell.user_ns based on the client that submits each request.</div>

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