On Tue, Dec 13, 2011 at 11:12 AM, Anthon van der Neut <[email protected]> wrote:
> I am sorry if I try to do something that pyjamas is not supposed to support.

 hey don't apologise, no need!

> I hope you understand that for someone who has a codebase a gradual
> transition would be nice (if possible).

 yes... although the most sensible option is probably either frames or
to use inter-communication.

> I will search for the 50 lines, so
> far I have either overlooked that example.

 it's not an example, it's a description of the adaptation required to
extract (only) 50 lines of code from the GWT codebase and insert them
into pyjamas.  take a look at RootPanel.java, paying attention to the
onWindowClose hooking and go from there.


>I will next go over the mailing
> list.
>
> Would I more likely not run into problems if I never remove the element that
> pyjamas has 'created'?

 that's missing the point: it's the fact that the DOM object that's
being "managed" by pyjamas has a circular dependency in the
javascript.  if you do half the job (i.e. don't ever call doDetach)
then you're guaranteed to end up with memory leaks.

 the infrastructure i mentioned exists in GWT for attaching to random
bits of DOM.


> Just to be clear: I do prefer not to mix managing the same part of the DOM
> tree with jQuery *and* Pyjamas. What I thought of doing is:
> 1) initiate the web page from web2py with an element with a specific ID
> 'abc' that gets replaced by a jQuery call.
> 2) the 'abc' element has somewhere a child element in its tree with ID 'xyz'
> 3) have the jQuery startup function initiate pyjamas to replace the xyz
> element, everything within that is managed by pyjamas

 yep that would work.  what i recommend you do is write a JS block
which declares a public javascript function, taking the id as an
argument, which then uses the {{}} auto-substitution stuff to call the
RootPanel.get()  so that'll be {{RootPanel}}.{{get}}(foo_id) or
something like that.


> 4) if a jQuery managed button is pressed, it replaces element with ID abc. I
> want  shut down pyjamas properly before doing so
> and afterwards reinitiate pyjamas to fill out element xyz again.

 you should just be able to do the detach etc.  hmmm... there isn't
such a function in RootPanel.py - could you add one which finds the
RootPanel by id in the rootPanels dictionary, removes it and then
calls onDetach() just like is done in RootPanelManager onWindowClose ?



> Apart from the proper shutdown in 4) I think this is working.
>
> However I will look into not doing the handling of button presses with
> jQuery essentially making element 'abc' and 'xyz' the same with a more
> complete pyjamas program. That would mean I only start pyjamas once and it
> should handle any further interaction under the element abc/xyz.
>
> WRT the RootPanel question: I provided RootPanel.get() with a string, But I
> thought RootPanel has no get method, and that causes the error.

def get(id=None):
    """

    """
    if rootPanels.has_key(id):
        return rootPanels[id]


looks like that function exists, to me, dude :)

l.

Reply via email to