glyph@divmod.com wrote:
On 21 Apr, 08:57 pm, maillists@ivsn.com wrote:
Hello All,
LiveElement is fantastic, but I'm too stupid to find out, how to put temporary page under sessiop URL... This work for js modules at start like: http://localhost:8080/user/<HASH clientID>/jsmodule/athena_test
I'd like to add temporary during run time something like: http://localhost:8080/user/<HASH clientID>/your_data page or staticFile, which should exists only few minutes.
How can I add a child to the livepage session path?
The magical hash URL you're referring to is just an alias for your page instance. So all you need to do is, in your LiveElement:
self.page.putChild("your_data", YourDataResource())
That YourDataResource() object (and its attendant URL) will then live as long as your LivePage connection does.
This is an interesting use-case, and it should work fine - but be aware that you're relying on a pretty weird little corner of implementation details here. It certainly never occurred to *me* that somebody would want to do this :).
Particularly, there's no public API for generating this URL; you'll have to rely on the fact that url.here.child(self.clientID) keeps working.
Thank you for that fast answer, I've tried before and now again, but this work only when one instance is running. If you try on i.e. chatterbox, after 2nd user join it is no more reliable, few times it works, but mostly not. I solved the problem by overriding locateChild in the top site instance of WidgetPluginRoot by checking segments[0] against all instances of elementFactory comparing their clientID and on match passing the request to own method added to LiveElement derived class. It is complicated, but seems to work... If there is an easier solution, I'll be happy. Caveat is, that instances of gone clients are keeping in memory. Is there a way to find out, that a client is gone (closed browser or switched to other site)? Thanks & regards, Paul