<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Jun 26, 2005, at 11:30 PM, Chris (FeedTagger) wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Sorry, just registered so unable to join existing thread.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I'm having similar problems that are outlined here:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://twistedmatrix.com/pipermail/twisted-web/2005-June/001523.html">http://twistedmatrix.com/pipermail/twisted-web/2005-June/001523.html</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">"I also can't see a way to use handler_* methods, because this methods</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">must be inside a rend.Fragment subclass in my case."</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>There's no way Nevow can automatically determine that a handler event should be dispatched to your Fragment instance, so you'll have to tell it. Your expectation below is correct:</DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I expect this can be rectified in livepage.py (line 728 on my co):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>def locateHandler(self, ctx, path, name):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">        </SPAN>### XXX TODO: Handle path</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">        </SPAN>return getattr(self, 'handle_%s' % (name, ))</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The path here is meant to be a string which names a Fragment or other dispatch path. As you can see, none of this is implemented yet, but this is my solution to this problem that you and others on this list have had. Basically the API in javascript would look something like this:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>server.handleWithPath('onclick', 'some/path', 'someArgument')</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>locateHandler would change to look more like locateChild, breaking apart the path into segments and consuming them until it locates the target. I'm not sure how the default locateHandler implementation will locate action targets; perhaps with dispatch_* prefixed methods? Here is a small example:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>class MainPage(Page):</DIV><DIV>    docFactory = loaders.xmlstring("""&lt;html xmlns:n="<A href="http://nevow.com/ns/nevow/0.1">http://nevow.com/ns/nevow/0.1</A>"&gt;</DIV><DIV>  &lt;a onclick="server.handleWithPath('onclick', 'someFragment', 'someArg')"&gt;</DIV><DIV>    Click me</DIV><DIV>  &lt;/a&gt;</DIV><DIV>  &lt;span n:render="liveid" /&gt;</DIV><DIV>  &lt;span n:render="liveglue" /&gt;</DIV><DIV>&lt;/html&gt;""")</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>    def dispatch_someFragment(self, ctx):</DIV><DIV>        return MyFragment()</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>class MyFragment(Fragment):</DIV><DIV>    def handle_onclick(self, ctx, someArg):</DIV><DIV>         assert someArg == 'someArg'</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Suggestions on different names other than "dispatch_*" are welcome; the main reason I haven't implemented this functionality yet is because I can't decide what to call it! :-)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#000000"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">My implementation is slightly different in that I'm not using</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">rend.Fragment, I have a Page broker that responds to requests and</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">returns a new page that implements from a master page.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--------------------------</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">myserver.py:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">pageMappings ] {</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">  </SPAN>'search': search.Page</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">  </SPAN>'index': index.Page</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">class Page(livepage.LivePage):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">  </SPAN>def locateChild(self,ctx,segments):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN># depending on the value of segments[0] return the correct page</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN># from a predefined map, otherwise 404</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>page = pageMappings[segments[0]]</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>return page(), segments[1]</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Then in index.Page.py:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">class Page(_master.FrontPage):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">  </SPAN>def render_button(self,ctx,data):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>return ctx.tag(onclick="server.handle('click')")</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">  </SPAN>def handle_click(self,ctx,client):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>client.alert('clicked button')</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_master.py:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">class CorePage(livepage.LivePage):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">  </SPAN># various properties that all generic pages should exhibit</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">class FrontPage(CorePage):</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">  </SPAN># load front page template</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">  </SPAN># provide any default slot fills etc.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--------------------</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Now the problem as I see it (with primitive livepage knowledge) is</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">that the livepage request that's sent with server.handle('click') is</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">attempting to be mapped to myserver.Page, instead of my intended</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">index.Page class.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Is it possible to provide this functionality or should this whole</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">template based approach be re-worked in some other fashion?</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Again, you want the above proposed architecture to be finished, but it isn't finished yet.</DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">... as a side note using a generic dispatcher of pages (myserver.Page)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I can do cool things like detect /xml appended to url and instead of</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">loading .xhtml templates, load the appropriate .xml templates. Hence</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">without changing any application code I can generate xml versions of</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">every single webpage across a site.</DIV></BLOCKQUOTE><BR></DIV><DIV>I suggest using a query parameter rather than an additional URL segment. xml is a different "view" of the same "object"; in my opinion, URLs should represent "objects" (Resources) and query parameters should be used to parameterize how the view renders. One might also be able to use the "Accept" header that browsers send to negotiate the rendered content type. But this is just a suggestion. Whatever works for you is fine with me :-)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>And yes, this is a cool capability to want to have.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Donovan</DIV><DIV><BR class="khtml-block-placeholder"></DIV></BODY></HTML>