
Hey guys, A harder question this time (well... maybe!) Using nevow.tags I want to emit a paragraph such as: <p class="dirItem">blah</p> Problem is, "class" is naturally a keyword so python won't let me do this: return T.p("class"=paraClass)[ T.a(href=url)[resourceName] ] but this is fine return T.p("id"=paraClass)[ T.a(href=url)[resourceName] ] its probably easy... any ideas? Thanks Ellers

On Saturday 10 April 2004 14:53, Ellers wrote:
Using nevow.tags I want to emit a paragraph such as: <p class="dirItem">blah</p> Problem is, "class" is naturally a keyword so python won't let me do this: return T.p("class"=paraClass)[ T.a(href=url)[resourceName] ]
Use a leading underscore to assign something to "class". Nevow will strip that out for you: return T.p(_class=paraClass)[...] -- Matthew Scott <spud@goldenspud.com>

On Sat, 10 Apr 2004 15:34:00 -0500, Matthew Scott <twisted@goldenspud.com> wrote:
On Saturday 10 April 2004 14:53, Ellers wrote:
Using nevow.tags I want to emit a paragraph such as: <p class="dirItem">blah</p> Problem is, "class" is naturally a keyword so python won't let me do this: return T.p("class"=paraClass)[ T.a(href=url)[resourceName] ]
Use a leading underscore to assign something to "class". Nevow will strip that out for you:
return T.p(_class=paraClass)[...]
Awesome - thanks!

At 2004-04-10 03:34 PM -0500, you wrote:
Use a leading underscore to assign something to "class". Nevow will strip that out for you:
return T.p(_class=paraClass)[...]
Argghhhhh! And all this time I've been doing tag = T.p()[...] tag.attributes['class']=paraClass I *hate* magical incantations. Otherwise, I rather like Nevow. :-) - Sam __________________________________________________________ Spinward Stars, LLC Samuel Reynolds Software Consulting and Development 303-805-1446 http://SpinwardStars.com/ sam@SpinwardStars.com

On Mon, 2004-04-12 at 02:05, Samuel Reynolds wrote:
At 2004-04-10 03:34 PM -0500, you wrote:
Use a leading underscore to assign something to "class". Nevow will strip that out for you:
return T.p(_class=paraClass)[...]
Argghhhhh! And all this time I've been doing tag = T.p()[...] tag.attributes['class']=paraClass
I *hate* magical incantations. Otherwise, I rather like Nevow. :-)
But the whole of Nevow's stan is magical. It's an abomination! A hideous abuse of Python's __getitem__ machinery! It's lovely :). If you really want to avoid _class (_for is another) you can do: attrs = {'class': paraClass} tag = T.p(**attrs)[...] or even: tag = T.p(**{'class': paraClass})[...] Cheers, Matt -- __ / \__ Matt Goodall, Pollenation Internet Ltd \__/ \ w: http://www.pollenation.net __/ \__/ e: matt@pollenation.net / \__/ \ t: +44 (0)113 2252500 \__/ \__/ / \ Any views expressed are my own and do not necessarily \__/ reflect the views of my employer.
participants (4)
-
Ellers
-
Matt Goodall
-
Matthew Scott
-
Samuel Reynolds