hi there

here's a smaller, hopefully more clearer example of a problem I have been stuck on. I should probably also lead off by saying that I think what I am asking is basically this question.

http://www.mail-archive.com/zope3-users@zope.org/msg00052.html

However I have read objectwidget.txt( http://svn.zope.org/Zope3/trunk/ src/zope/app/form/browser/objectwidget.txt ) several times and I don't see where a "custom widget" gets created. I also suspect that because the "object" I need to create a custom widget for has more than just one field I have to do something different.

If there's a short fix for the problem that would be great, otherwise a little explanation to point me in the right direction would be greatly appreciated too.

thanks.

-jachin

Here's the error I'm getting any my code:

2006-05-11T11:56:47 ERROR SiteError http://localhost:8080/@@+/ action.html
Traceback (most recent call last):
File "/usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py", line 138, in publish
    result = publication.callObject(request, object)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/publication/ zopepublication.py", line 161, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
File "/usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py", line 113, in mapply
    return debug_call(object, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py", line 119, in debug_call
    return object(*args)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/container/browser/ adding.py", line 128, in action
    name=view_name) is not None:
File "/usr/local/Zope-3.2.1/lib/python/zope/component/ __init__.py", line 165, in queryMultiAdapter return sitemanager.queryMultiAdapter(objects, interface, name, default) File "/usr/local/Zope-3.2.1/lib/python/zope/component/site.py", line 75, in queryMultiAdapter
    default)
File "/usr/local/Zope-3.2.1/lib/python/zope/interface/adapter.py", line 475, in queryMultiAdapter
    return factory(*objects)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/ editview.py", line 64, in __init__
    self._setUpWidgets()
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/ add.py", line 49, in _setUpWidgets setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames) File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py", line 153, in setUpWidgets
    context=context)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py", line 97, in setUpWidget
    widget = _createWidget(context, field, viewType, view.request)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py", line 65, in _createWidget
    return zapi.getMultiAdapter((field, request), viewType)
File "/usr/local/Zope-3.2.1/lib/python/zope/component/ __init__.py", line 154, in getMultiAdapter
    raise ComponentLookupError(objects, interface, name)
ComponentLookupError: ((<zope.schema._field.Object object at 0x4282b70>, <zope.publisher.browser.BrowserRequest instance URL=http://localhost:8080/@@+/action.html>), <InterfaceClass zope.app.form.interfaces.IInputWidget>, u'') 127.0.0.1 - - [11/May/2006:11:56:47 -0500] "GET /@@+/action.html? type_name=AddPerson.html HTTP/1.1" 500 84 "http://localhost:8080/ @@contents.html" "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en- US; rv:1.8.0.3) Gecko/20060427 Camino/1.0.1"

------------interfaces.py----------------

from zope.interface import Interface
import zope.schema

class IStreetAddress(Interface):
        """A vine street address"""
        
        street = zope.schema.Text (
                title=u"Street 1",
                description=u"The street address",
                required = False
        )
        
        city = zope.schema.TextLine (
                title=u"City",
                description=u"The city.",
                required = False
        )
        
        state = zope.schema.TextLine (
                title=u"State",
                description=u"The state.",
                required = False
        )
        
        zipcode = zope.schema.TextLine (
                title=u"Zip Code",
                description=u"The zip code",
                required = False,
                min_length = 5
        )


class IPerson(Interface):
        firstName = zope.schema.TextLine (
                title=u"First Name",
                description=u"The person's first name",
                required=False
        )
        
        lastName = zope.schema.TextLine (
                title=u"Last Name",
                description=u"The person's last name",
                required=False
        )
        
        address = zope.schema.Object (
                title=u"Address",
                description=u"The person's adderess",
                required=False,
                schema = IStreetAddress
        )
        

------------person.py----------------

from persistent import Persistent
from zope.interface import implements

from abook.interfaces import IPerson
from abook.streetAddress import StreetAddress

class Person(Persistent):
        
        implements(IPerson)
        
        firstName = u""
        lastName = u""
        address = StreetAddress()


------------configure.zcml------------

<configure
        xmlns="http://namespaces.zope.org/zope";
        xmlns:browser="http://namespaces.zope.org/browser";
        xmlns:i18n="http://namespaces.zope.org/i18n";
        i18n_domain="abook">
        
        <!-- Person -->
        
        <interface
                interface       = ".interfaces.IPerson"
                type            = "zope.app.content.interfaces.IContentType"
                />
                
        <content class = ".person.Person">
                <factory
                        id                      = "simple_abook.person.Person"
                        description     = "A Person"
                        />
                <require
                        permission      = "zope.View"
                        interface       = ".interfaces.IPerson"
                        />
                <require
                        permission      = "zope.View"
                        set_schema      = ".interfaces.IPerson"
                        />
        </content>
        
        <browser:addform
                label                   = "Add a Person"
                fields                  = "firstName lastName address"
                name                    = "AddPerson.html"
                schema                  = ".interfaces.IPerson"
                content_factory = ".person.Person"
                permission              = "zope.View"
                />
        
        <browser:editform
                label                   = "Edit a Person"
                schema                  = ".interfaces.IPerson"
                for                             = ".interfaces.IPerson"
                fields                  = "firstName lastName address"
                name                    = "edit.html"
                permission              = "zope.View"
                menu                    = "zmi_views"
                title                   = "Edit"
                />
                
        <browser:addMenuItem
                title                   = "A Person"
                description             = "Add a Person"
                view                    = "AddPerson.html"
                class                   = ".person.Person"
                permission              = "zope.View"
                />
        
</configure>


_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to