[Twisted-web] data in a form

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


    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:


class ISomething(annotate.TypedInterface):

    def doSomething(
        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">
                <th><n:slot name="label"/>:</th>
                <td><n:slot name="input"/><span
class="freeform-error"><n:slot name="error"/></span></td>
                <td><n:slot name="description"/></td>
              <td colspan="2">
                <n:slot name="form-button"/>

application = service.Application("disktemplates")


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

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.


More information about the Twisted-web mailing list