[Twisted-web] data in a form

vicky vlupien at drummonddesigns.com
Mon Jul 5 12:40:51 MDT 2004


Hi,

    I have a little problem.  I want to use a nevow:data="test2" in a form
but I got this error:

nevow.accessors.NoAccessor: <MethodBinding doSomething=Method at 0xc4cd30>
does not implement IContainer, and there is no registered adapter.

Here's my code:

############disktemplates.tac

class ISomething(annotate.TypedInterface):

    def doSomething(
        self,
        ctx = annotate.Context(),
        fee = annotate.String(required=True, description="Wee!"),
        ):
        """"""
    doSomething = annotate.autocallable(doSomething)

class Mine(rend.Page):
    __implements__ = ISomething, rend.Page.__implements__

    docFactory = loaders.htmlfile('disktemplates.html')

    def data_test(self, context, data):
        return "coucou"

    def render_test(self, context, data):
        return T.span()[data]

    def data_test2(self, context, data):
        return "test2!"

    def render_test2(self, context, data):
        return T.span()[data]

    def doSomething(self, ctx, **kwargs):
        print '***** doSomething called with:', kwargs

    def render_customForm(self, ctx, data):
        return webform.renderForms()[self.FORM_LAYOUT]

    FORM_LAYOUT = loaders.xmlstr("""<form
xmlns:n="http://nevow.com/ns/nevow/0.1" n:pattern="freeform-form">

          <n:attr name="action"><n:slot name="form-action"/></n:attr>
          <n:attr name="id"><n:slot name="form-id"/></n:attr>
          <n:attr name="name"><n:slot name="form-name"/></n:attr>

          <span n:data="test2" n:render="test2" />
          <table style="background: #eee; border: 1px solid #bbb; padding:
1em;" >
            <n:slot name="form-arguments"/>
            <n:invisible n:pattern="argument" n:render="remove">
              <tr>
                <th><n:slot name="label"/>:</th>
                <td><n:slot name="input"/><span
class="freeform-error"><n:slot name="error"/></span></td>
              </tr>
              <tr>
                <th></th>
                <td><n:slot name="description"/></td>
              </tr>
            </n:invisible>
            <tr>
              <td colspan="2">
                <n:slot name="form-button"/>
              </td>
            </tr>
          </table>
        </form>""").load()

application = service.Application("disktemplates")
internet.TCPServer(8080,
appserver.NevowSite(Mine())).setServiceParent(application)


#########disktemplates.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>This is title</title>
	</head>
	<body>
		<span nevow:data="test" nevow:render="test" />
		<span nevow:render="customForm" />
	</body>
</html>

---------------------------------------
The nevow:data in disktemplates.html is ok but the one in FORM_LAYOUT is not
working.  I really need to have an nevow:data="??" in my form.  Maybe I'm
doing something wrong.

Vicky





More information about the Twisted-web mailing list