[Product-Developers] z3c.form with Boring

David Zejda dvid at atlas.cz
Sun Mar 22 21:26:01 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I'm playing with a simple product called JWFind, derived from Boring
(http://www.zope.org/Members/gtk/Boring) now. The product sits in the
products directory, can be added and removed using ZMI, it seems OK.

Because I'm willing to use it in Plone, the Zope version is 2.10.6-final.

Now, I'm trying to handle the view of product using form made of
z3c.form. There is a problem. Currently, I'm getting

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.JWFind.JWFind, line 55, in index_html
  Module z3c.form.form, line 189, in __call__
  Module z3c.form.form, line 184, in update
  Module z3c.form.form, line 134, in update
  Module z3c.form.form, line 120, in updateWidgets
  Module zope.component._api, line 103, in getMultiAdapter
  Module zope.component._api, line 103, in getMultiAdapter
ComponentLookupError: ((<Products.JWFind.Person.Person object at
0xb5003b2c>, <HTTPRequest, URL=http://localhost:8091/pokus/index_html>,
<JWFind at /pokus>), <InterfaceClass z3c.form.interfaces.IWidgets>, u'')

I guess, the error tells, that something implementing ``IWidgets``
cannot be found. But, I have no idea, how to deal with it. Maybe, should
I prepare the specific layer and skin to be able to use z3cforms and If
so, how to do it and especially how to register it properly? Or is there
a problem with the form definition itself? Or should I register
something to zope in addition to registration made in __init__?

The relevant part of product source JWFind.py:

    def index_html(self, REQUEST=None):
	"""JWFind Form"""
	out = Person(self, REQUEST)()
	return out.PersonView

The form is in separate file Person.py:

from zope import interface, schema
from z3c.form import form, field, button
from plone.app.z3cform.layout import wrap_form

class IPerson(interface.Interface):
    age = schema.Int(
	title=u"Age",
	required=True)

class Person(form.Form):
     fields = field.Fields(IPerson)
     ignoreContext = True # don't use context to get widget data
     label = u"Please enter your age"

     @button.buttonAndHandler(u'Apply')
     def handleApply(self, action):
         data, errors = self.extractData()
         print data['age'] # ... or do stuff

PersonView = wrap_form(Person)

The whole source is attached.

Please, any ideas?

Thanks a lot..

David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknGrOkACgkQ3oCkkciamVFB6wCfXAVRUT9CrdzBjra4dUdlEsGC
vkUAn3j12om9v8TttUGn/fZ/bnAWeBhe
=z+Ua
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JWFind.tar.gz
Type: application/gzip
Size: 2483 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20090322/a1380902/attachment.bin>


More information about the Product-Developers mailing list