Nevow - newbie stan question

"Harald Blåtand" <[email protected]> Mon, 3 Mar 2008 13:03:42 +0100
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
--===============1262231911==
Content-Type: multipart/alternative; 
	boundary="----=_Part_313_12854484.1204545823073"

------=_Part_313_12854484.1204545823073
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi all,
Learning Nevow & Athena; seems xtremely good; however, right now I'm stuck
on the case below, & my head's spinning a bit.
Like the 2 commented lines show, I'm trying to set the <select>'s name
attribute from a parameter, and can't figure out how.

Any hint, please?
k

class Selector(rend.Page):                      # HTML for a <SELECT>
element. Called with SQL result list.
    docFactory = loaders.stan(
        T.select(
                 #name= ???                                           # How
do I fill this?
                 render=T.directive('sequence')
                )[
            T.option(pattern = 'item', render = T.directive('option'))
            ]
        )

    def render_option(self, ctx, data):
        return ctx.tag(value='%s' % str(data[1]))[ unicode(data[0])]


    @defer.inlineCallbacks
    def _select(self, name, sql):
        result = yield self._sqlCachedQuery(sql)
        defer.returnValue(Selector([['', -1]] +
sorted(result)))                       # Works fine so far
        #defer.returnValue(Selector([name, [['', -1]] +
sorted(result)]))       # How can I call it with this (sort of) instead?

------=_Part_313_12854484.1204545823073
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div>Hi all,</div>
<div>Learning Nevow &amp; Athena; seems xtremely good; however, right now I&#39;m stuck on the case below, &amp; my head&#39;s spinning a bit.</div>
<div>Like the 2 commented lines show, I&#39;m trying to set the &lt;select&gt;&#39;s name attribute from a parameter, and can&#39;t figure out how.</div>
<div>&nbsp;</div>
<div>Any hint, please?</div>
<div>k</div>
<div>&nbsp;</div>
<div>class Selector(rend.Page):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# HTML for a &lt;SELECT&gt; element. Called with SQL result list.<br>&nbsp;&nbsp;&nbsp; docFactory = loaders.stan(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T.select(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #name= ???&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # How do I fill this?<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; render=T.directive(&#39;sequence&#39;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )[<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T.option(pattern = &#39;item&#39;, render = T.directive(&#39;option&#39;))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp; def render_option(self, ctx, data):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ctx.tag(value=&#39;%s&#39; % str(data[1]))[ unicode(data[0])]</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp; @defer.inlineCallbacks<br>&nbsp;&nbsp;&nbsp; def _select(self, name, sql):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = yield self._sqlCachedQuery(sql)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; defer.returnValue(Selector([[&#39;&#39;, -1]] + sorted(result)))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Works fine so far<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #defer.returnValue(Selector([name, [[&#39;&#39;, -1]] + sorted(result)]))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # How can I call it with this (sort of) instead?<br></div>

------=_Part_313_12854484.1204545823073--


--===============1262231911==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline