<div dir="ltr"><div class="gmail_extra"></div><div class="gmail_extra"><div class="gmail_quote">On 17 June 2014 06:37, Nicholas Bollweg <span dir="ltr"><<a href="mailto:nick.bollweg@gmail.com" target="_blank">nick.bollweg@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>We have also encountered this issue: we have, for the moment, dealt with it with a mixin for our python-side widget classes that does a require against the <span style="font-family:courier new,monospace">_view_name</span>:<br>


</div></blockquote><div><br></div><div>Ah, I was trying to load the JS by displaying HTML with a script tag. I guess displaying actual javascript directly reduces the async problem. All the same, I think a cleaner solution would definitely be good.<br>


<br></div><div>I was discussing this with Jon yesterday, and we're thinking of changing around the current scheme a bit, so that rather than registering target types with the comm manager, and view types with the widget manager, widgets are define in modules that can be loaded by require.js. Then a widget that currently specifies a view_name will also specify a view_module. So in your case, the code would look like this:<br>


<br></div><div>class MyWidget(Widget):<br></div><div>    view_name = 'WidgetView'<br></div><div>    view_module = '/nbextensions/ipynbdbtk/js'<br>    ...<br><br></div><div>This would result in some incompatibility with existing code, but it should be possible to update extensions so that they'll work with IPython 2 and 3. Given that widgets are new, and the APIs somewhat provisional, I think that's acceptable. We intend to update all of our own widgets to use this, and get rid of the JS type registries altogether.<br>


</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Speaking of documentation: a template for building extensions with widgets that that embodied the baseline of knowledge spread all over the community would be great. I have used paste before, which seems kind of heavy these days. Cookiecutter looks good:</div>


</blockquote></div><br></div><div class="gmail_extra">I think we're really still working out what best practices are - and updating IPython's APIs as we work out things like this. By all means create a template, though - it can evolve as our knowledge and APIs improve.<br>

<br></div><div class="gmail_extra">Andrew:<br>> I'm not sure, but this <i>sorta</i> looks like the same issue I raised in the thread titled "Javascript ordering semantics". Here's the solution I found then:...<br>

<br></div><div class="gmail_extra">You're quite right, it is exactly the same issue. I wasn't using widgets then, so I didn't pay much attention to the thread. I think your solution is similar to Nicholas', except with the added publication of an HTML element. In my code, the HTML components are created in JS when the widget is displayed.<br>

<br></div><div class="gmail_extra">I still think it's worth improving this API in IPython, but I will work in this solution to support widgets in IPython 2.<br><br></div><div class="gmail_extra">Thanks,<br>Thomas<br>

</div></div>