<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">El 08/08/13 06:17, Gabriel Becker
      escribió:<br>
    </div>
    <blockquote
cite="mid:CADwqtCOPAxGayPHN4c=Buo0MebYsB06VS-zy-eD3gmcuJd79yg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>
                <div>Damian,<br>
                  <br>
                </div>
                I happen to be familiar with this issue for reasons that
                dovetail with your desired usecase (though they aren't
                identical). More on that near the end of this email.<br>
                <br>
                The issue you're running into is that the javascript in
                the IPython notebook assumes that all cells are direct
                children of the container element representing the
                entire notebook.<br>
                <br>
                You can see the assumption here (from
                IPython/html/static/notebook/notebook.js)<br>
                <br>
                <div class="" id="LC441">   <span class="">/**</span></div>
                <div class="" id="LC442"><span class=""> * Get all cell
                    elements in the notebook.</span></div>
                <div class="" id="LC443"><span class=""> * </span></div>
                <div class="" id="LC444"><span class=""> * @method
                    get_cell_elements</span></div>
                <div class="" id="LC445"><span class=""> * @return
                    {jQuery} A selector of all cell elements</span></div>
                <div class="" id="LC446"><span class=""> */</span></div>
                <div class="" id="LC447">    <span class="">Notebook</span><span
                    class="">.</span><span class="">prototype</span><span
                    class="">.</span><span class="">get_cell_elements</span>
                  <span class="">=</span> <span class="">function</span>
                  <span class="">()</span> <span class="">{</span></div>
                <div class="" id="LC448">        <span class="">return</span>
                  <span class="">this</span><span class="">.</span><span
                    class="">container</span><span class="">.</span><span
                    class="">children</span><span class="">(</span><span
                    class="">"div.cell"</span><span class="">);</span></div>
                <div class="" id="LC449">    <span class="">};</span></div>
                <br>
              </div>
              Note the use of the children() method. That is what is
              killing you. All of the indexing, etc in notebook.js is
              based off of what is returned from get_cell_elements.<br>
              <br>
            </div>
            Matthias is of course correct that the cell still exists,
            and all the cell-level machinery will still work (thus
            ccell.execute() working fine).<br>
            <br>
            The issue is that NONE of the notebook-level machinery is
            going to work. This means many of the things you probably
            think of as core behaviors of the notebook (selecting the
            next cell when a cell is executed, deleting or moving cells,
            running the entire notebook from start to finish, the
            notebook understanding that that cell is selected, etc) will
            fail with respect to that particular cell, because as far as
            the notebook-level js is concerned, the cell <i>isn't in
              the notebook at all</i>. <br>
            <br>
          </div>
          I have a research-stage fork of ipython at <a
            moz-do-not-send="true"
            href="https://github.com/gmbecker/ipython">https://github.com/gmbecker/ipython</a>
          which allows cells to be contained within other cells. This
          required me to change the indexing strategy, which is why I'm
          familiar with this bit of the codebase. <br>
          <br>
          Nested cells would remove the need for the extra container
          div, because the grouping would be happening within the cells
          themselves. You would assumedly be able to just attach the
          css/js slide machinery to the parent grouping cells
          themselves.<br>
          <br>
          There was a very lengthy discussion about the concept of these
          nesting type cells, their benefits and their drawbacks, and
          whether they should be pursued <a moz-do-not-send="true"
href="http://python.6.x6.nabble.com/Some-new-cell-types-for-describing-data-analyses-in-IPy-Notebook-td5023238.html">here</a>. 

          The long and short (AFAIK) of it is that the IPython core team
          is not yet convinced that the idea is mature enough to pursue.
          Furthermore, the fact that it requires modification of a core
          assumption of the notebook machinery makes such pursuit
          unlikely in at least the short and medium terms, if ever.<br>
          <br>
        </div>
        <div>The team is, of course, also very busy doing all sorts of
          other awesome stuff as detailed on their roadmap.<br>
          <br>
        </div>
        <div>Anyway, all that doesn't really help you now. Here is
          something that might:<br>
          <br>
          If custom js/extensions are able to clobber core machinery on
          the IPython object then replacing
          IPython.Notebook.prototype.get_cell_elements with<br>
          <br>
          /**<br>
        </div>
        <div>** Version of get_cell_elements that will see cell divs at
          any depth in the HTML tree, allowing container divs, etc to be
          used without breaking notebook machinery.<br>
        </div>
        <div>** You'll need to make sure the cells are getting detected
          in the right order, but I think they will<br>
          **/<br>
        </div>
        <div>
          <div class="" id="LC447">    <span class="">Notebook</span><span
              class="">.</span><span class="">prototype</span><span
              class="">.</span><span class="">get_cell_elements</span> <span
              class="">=</span> <span class="">function</span> <span
              class="">()</span> <span class="">{</span></div>
          <div class="" id="LC448">        <span class="">return</span>
            <span class="">this</span><span class="">.</span><span
              class="">container</span><span class="">.<b>find</b></span><span
              class="">(</span><span class="">"div.cell"</span><span
              class="">);</span></div>
          <div class="" id="LC449">    <span class="">};<br>
            </span></div>
          <div class="" id="LC449"><span class=""><br>
              Will get your cell noticed again. Or, if extensions get
              loaded after the notebook object exists, you might have to
              modify the actual notebook instead of its prototype. That
              is stored in IPython.notebook if I'm not mistaken.<br>
              <br>
            </span></div>
          <div class="" id="LC449"><span class="">Figuring out how to
              get the notebook to store (in ipynb form), remember, and
              restore the fact that you grouped your cells into slides
              is possible in principle using the metadata facilities
              already in place. Because the metadata is at the
              individual cell level, however, prepare for some "fun"
              hackrobatics implementing the ability to track the
              groupings in a non-fragile way (e.g. able to handle
              regrouping or inserting new slides).<br>
            </span></div>
          <div class="" id="LC449"><span class=""><br>
            </span></div>
          If the core machinery is protected from modification by js in
          the extensions somehow I think it would take a <i>lot</i> of
          wheel reinvention on your part or intervention from the core
          devs to get the functionality you want.<br>
          <br>
        </div>
        <div>HTH.<br>
        </div>
        <div>~G<br>
          <br>
        </div>
        <div>... Someday I will write a message to this list that isn't
          a novel. But not today.<br>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote"> On Wed, Aug 7, 2013 at 11:53 PM,
          Damián Avila <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:damianavila@gmail.com" target="_blank">damianavila@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>El 08/08/13 03:26, Matthias BUSSONNIER escribió:<br>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5"><br>
                    <div>
                      <div>Le 8 août 2013 à 08:01, Damián Avila a écrit
                        :</div>
                      <br>
                      <blockquote type="cite"><span
style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium">In

                          this way, I get the a copy of the cell but it
                          is not executable…</span></blockquote>
                      <br>
                    </div>
                    <div><br>
                    </div>
                    <div>Yes it is, Shift-Enter is just not bound to
                      it. </div>
                    <div>Shift-Enter is handled by IPython.notebook and
                      is bound to execute selected cell</div>
                    <div><br>
                    </div>
                    <div>As notebook object does nt know of your
                      cell, you are just sending the execute request to
                      the wrong cell.</div>
                    <div><br>
                    </div>
                    <div>adding this : </div>
                    <div><br>
                    </div>
                    <div>window.ccell = cell;</div>
                    <div><br>
                    </div>
                    <div>and then ccell.execute() in JSconsole works.</div>
                    <div><br>
                    </div>
                    <div>-- </div>
                    <div>M</div>
                    <br>
                    <br>
                    <fieldset></fieldset>
                    <br>
                  </div>
                </div>
                <div class="im">
                  <pre>_______________________________________________
IPython-dev mailing list
<a moz-do-not-send="true" href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a>
<a moz-do-not-send="true" href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a>
</pre>
                </div>
              </blockquote>
              <br>
              Thanks! I will test it tomorrow... going to bed now...
              thanks! <br>
              <br>
              One step closer to "live" reveal ;-)<br>
              <br>
              Cheers.<span class="HOEnZb"><font color="#888888"><br>
                  <br>
                  Damián.<br>
                </font></span></div>
            <br>
            _______________________________________________<br>
            IPython-dev mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
            <a moz-do-not-send="true"
              href="http://mail.scipy.org/mailman/listinfo/ipython-dev"
              target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        Gabriel Becker<br>
        Graduate Student<br>
        Statistics Department<br>
        University of California, Davis<br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
IPython-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/ipython-dev">http://mail.scipy.org/mailman/listinfo/ipython-dev</a>
</pre>
    </blockquote>
    <br>
    <br>
    Gabriel, thank for your tip... It was very very helpful... Now, I
    can run the cells wrapped inside new divs...<br>
    OK, time to deal with metadata and grouping of the cells...<br>
    Seriously, you help and the detail description is very
    appreciated...<br>
    BTW, I will probably go deeper in your fork to take some ideas...<br>
    <br>
    Cheers.<br>
    <br>
    Damián.<br>
    <br>
  </body>
</html>