[Zope3-Users] formlib confusion

Pete Taylor baldtrol at gmail.com
Thu Apr 6 10:41:12 EDT 2006


hi all...  i've recently tried to start moving away from
zope.app.form.browser.editview's EditView, and to zope.formlib.form's
Form and EditForm, but have run into something that confuses me.

i'm setting up the zcml for both of them basically the same way, using
browser:page and assigning a template.  my issue is that it doesn't
seem like EditForm is paying any attention to my page template.  no
matter what i do to the page template, nothing changes in the display,
but if i remove the page template entirely, i get a system error
saying it can't find the resource, just like i'd expect.

so the machinery is aware of the page template, but seems to ignore it
entirely.

my class looks something like the following... the actions are just
placeholders until i figure out why the page template doesn't seem to
have any affect.

<code>

class ConsumerRegistrarForm(form.Form):
 	    """form to be filled out at signup"""
 	    form_fields = form.Fields(IConsumerRegistrar,
IConsumerPrincipalInfo, omit_readonly=True)
 	
 	    primary_actions = form.Actions()
 	    secondary_actions = form.Actions()
 	
 	    @zope.cachedescriptors.property.Lazy
 	    def actions(self):
 	        return list(self.primary_actions) + list(self.secondary_actions)
 	
 	    @form.action(u'Register', primary_actions)
 	    def handle_registration_action(self, action, data):
 	        self.status = u"You clicked the button!"
 	
 	    @form.action(u'SomethingElse', secondary_actions)
 	    def handle_somethingelse_action(self, action, data):
 	        self.status = u'This does nothing!'
 	
 	    def setUpWidgets(self, ignore_request=False):
 	        self.widgets = form.setUpWidgets(
 	            self.form_fields, self.prefix, self.context, self.request,
 	            ignore_request=ignore_request
 	            )

</code>

<zcml_config>

  <!-- consumer registar -->
 	  <browser:addform
 	      schema="..interfaces.registration.IConsumerRegistrar"
 	      label="Add Consumer Registrar"
 	      content_factory="..registration.ConsumerRegistrar"
 	      name="AddConsumerRegistrar.html"
 	      permission="zope.ManageServices"
 	      />
 	
 	  <browser:addMenuItem
 	      title="Consumer Registrar"
 	      description="Consumer Registrar"
 	      class="..registration.ConsumerRegistrar"
 	      permission="zope.ManageServices"
 	      view="AddConsumerRegistrar.html"
 	      />
 	
 	  <browser:page
 	      for="..interfaces.registration.IConsumerRegistrar"
 	      class=".registration.ConsumerRegistrarForm"
 	      template="registrar.zpt"
 	      name="register.html"
 	      permission="zope.Public"
 	      />
 	
 	  <browser:page
 	      for="..interfaces.principal.IConsumerPrincipalInfo"
 	      class=".registration.ConsumerRegistrarForm"
 	      template="registrar.zpt"
 	      name="register.html"
 	      permission="zope.Public"
 	      />

</zcml_config>

any thoughts on this would be very appreciated...  my original page
template was so simple that i didn't notice it wasn't having any
affect.  but once i started adding viewlets to it that didn't show up
in view source at all, i realized something was amiss.  i deleted
everything except the bare skeleton, including all metal:use-macro
statements in my page template, and still, the view kept showing up
exactly the same way.  even just making it blank html that said "I am
the page template!" for the body didn't make any difference to the
view, which makes me think it's paying no attention to it at all.

Thanks, as always :)
Pete

--
"All guilt is relative, loyalty counts, and never let your conscience
be your guide."
  - Lucas Buck, American Gothic


More information about the Zope3-users mailing list