[Zope3-Users] ComponentLookupError
Jachin Rupe
jachin at voltzsoftware.com
Mon May 15 18:39:06 EDT 2006
hi there
thanks for the help... but I have a new problem. Now the addForm
show up but if I try to actually add a person I get the following error:
2006-05-15T17:19:42 ERROR SiteError http://localhost:8080/+/
AddPerson.html%3D
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/pagetemplate/
simpleviewclass.py", line 44, in __call__
return self.index(*args, **kw)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/
viewpagetemplatefile.py", line 83, in __call__
return self.im_func(im_self, *args, **kw)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/
viewpagetemplatefile.py", line 51, in __call__
sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
File "/usr/local/Zope-3.2.1/lib/python/zope/pagetemplate/
pagetemplate.py", line 117, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 277, in __call__
self.interpret(self.program)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 908, in do_useMacro
self.interpret(macro)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 538, in do_optTag_tal
self.do_optTag(stuff)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 523, in do_optTag
return self.no_tag(start, program)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 518, in no_tag
self.interpret(program)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 878, in do_defineMacro
self.interpret(macro)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 976, in do_defineSlot
self.interpret(block)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 966, in do_defineSlot
self.interpret(slot)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 878, in do_defineMacro
self.interpret(macro)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 878, in do_defineMacro
self.interpret(macro)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 588, in do_setLocal_tal
self.engine.setLocal(name, self.engine.evaluateValue(expr))
File "/usr/local/Zope-3.2.1/lib/python/zope/tales/tales.py", line
696, in evaluate
return expression(self)
File "/usr/local/Zope-3.2.1/lib/python/zope/tales/expressions.py",
line 205, in __call__
return self._eval(econtext)
File "/usr/local/Zope-3.2.1/lib/python/zope/tales/expressions.py",
line 199, in _eval
return ob()
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/
add.py", line 62, in update
self.createAndAdd(data)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/
add.py", line 115, in createAndAdd
adapted = self.schema(content)
File "/usr/local/Zope-3.2.1/lib/python/zope/interface/
interface.py", line 682, in __call__
raise TypeError("Could not adapt", obj, self)
TypeError: ('Could not adapt', <simple_abook.person.Person object at
0x3b3a6f0>, <InterfaceClass simple_abook.interfaces.IPerson>)
I think this is saying that it can't adapt my Person object to the
IPerson interface.
Am I still missing something?
Now for the sake of completeness here's the rest of the example so
everyone can be on the same page:
########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>
<content class = ".streetAddress.StreetAddress">
<factory
id = "simple_abook.person.StreetAddress"
description = "A Person"
/>
<require
permission = "zope.View"
interface = ".interfaces.IStreetAddress"
/>
<require
permission = "zope.View"
set_schema = ".interfaces.IStreetAddress"
/>
</content>
<browser:addform
label = "Add a Person"
fields = "firstName lastName address"
name = "AddPerson.html"
schema = ".interfaces.IPerson"
content_factory = ".person.Person"
class = ".browser.PersonAddView"
permission = "zope.View"
/>
<browser:editform
label = "Edit a Person"
schema = ".interfaces.IPerson"
for = ".interfaces.IPerson"
fields = "firstName lastName address"
name = "edit.html"
class = ".browser.PersonEditView"
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>
########browser.py#########
from zope.app.form.browser.editview import EditView
from zope.app.form.browser.add import AddView
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import ObjectWidget
from interfaces import IPerson
from person import Person
from streetAddress import StreetAddress
st = CustomWidgetFactory(ObjectWidget, StreetAddress)
class PersonEditView(EditView):
__used_for__ = IPerson
address_widget = st
class PersonAddView(AddView):
__used_for__ = IPerson
address_widget = st
########interfaces.py#########
from zope.interface import Interface
import zope.schema
class IStreetAddress(Interface):
"""A vine street address"""
street = zope.schema.Text (
title=u"Street",
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()
########streetAddress.py#########
from persistent import Persistent
from zope.interface import implements
from abook.interfaces import IStreetAddress
class StreetAddress(Persistent):
implements(IStreetAddress)
street = u""
city = u""
state = u""
zipcode = u""
On May 12, 2006, at 6:42 AM, Egon Frerich wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Jachin,
>
> with these changes your application works:
>
>
> (new)
> - ---- browser.py ----
>
> from zope.app.form.browser.editview import EditView
> from zope.app.form.browser.add import AddView
> from zope.app.form import CustomWidgetFactory
> from zope.app.form.browser import ObjectWidget
>
> from interfaces import IPerson
> from person import Person
> from streetAddress import StreetAddress
>
>
> st = CustomWidgetFactory(ObjectWidget, StreetAddress)
>
> class PersonEditView(EditView):
> __used_for__ = IPerson
>
> address_widget = st
>
> class PersonAddView(AddView):
> __used_for__ = IPerson
>
> address_widget = st
>
> - ----- 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>
>
> <content class = ".streetAddress.StreetAddress">
> <factory
> id = "simple_abook.person.StreetAddress"
> description = "A Person"
> />
> <require
> permission = "zope.View"
> interface = ".interfaces.IStreetAddress"
> />
> <require
> permission = "zope.View"
> set_schema = ".interfaces.IStreetAddress"
> />
> </content>
>
>
> <browser:addform
> label = "Add a Person"
> fields = "firstName lastName address"
> name = "AddPerson.html"
> schema = ".interfaces.IPerson"
> content_factory = ".person.Person"
> class=".browser.PersonAddView"
> permission = "zope.View"
> />
>
> <browser:editform
> label = "Edit a Person"
> schema = ".interfaces.IPerson"
> for = ".interfaces.IPerson"
> fields = "firstName lastName address"
> name = "edit.html"
> class=".browser.PersonEditView"
> 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>
> - -------- --------
>
>
> Regards,
>
> Egon
>
> - --
> Egon Frerich, Freudenbergstr. 16, 28213 Bremen
>
> E-Mail: e.frerich at nord-com.net
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (MingW32)
> Comment: GnuPT 2.7.2
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFEZHSiuTzybIiyjvURAjtUAKCBUauLTFzO+soS/N8RWPO4N5SG8ACfalVY
> jvkyaY1jfGjM9/I1g/5HbLE=
> =Elf8
> -----END PGP SIGNATURE-----
More information about the Zope3-users
mailing list