[Grok-dev] Containment Contraints

Jeroen Michiel jmichiel at yahoo.com
Tue Apr 21 10:03:04 EDT 2009



Hugo Lopes-2 wrote:
> 
> Jeroen, I didn't understand your "test" (IFooContainer and IFoo).
> Can you pastebin?
> And the traceback would be nice, too.
> 

I'm trying to do this:

from zope.container.constraints import containers, contains 

class IFooContainer(Interface):
    contains('test.app.IFoo')

class FooContainer(grok.Container):
    grok.implements(IFooContainer)
    
class Test(grok.Application, grok.Container):
    grok.local_utility(FooContainer, provides=IFooContainer, public=True,
name_in_container='foos')

class IFoo(Interface):
    containers('test.app.IFooContainer')
    bar = schema.TextLine(title=u'Title')
    
class Foo(grok.Model):
    grok.implements(IFoo)
    
class AddFoo(grok.AddForm):
    grok.context(IFooContainer)
    form_fields = grok.AutoFields(IFoo)
    grok.name('add')
    
    @grok.action('Add')
    def Add(self, **data):
        foo = Foo()
        self.applyData(foo, **data)
        self.context[foo.bar] = foo
        self.redirect(self.url(foo))

If you then go to http://localhost:8080/test/foos/add
you get this dump:
Traceback (most recent call last):
  File
"c:\docume~1\jm\buildo~1\eggs\zope.publisher-3.4.6-py2.4.egg\zope\publisher\publish.py",
line 133, in publish
    result = publication.callObject(request, obj)
  File
"c:\docume~1\jm\buildo~1\eggs\grok-1.0a1-py2.4.egg\grok\publication.py",
line 91, in callObject
    return super(ZopePublicationSansProxy, self).callObject(request, ob)
  File
"c:\docume~1\jm\buildo~1\eggs\zope.app.publication-3.4.3-py2.4.egg\zope\app\publication\zopepublication.py",
line 167, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
  File
"c:\docume~1\jm\buildo~1\eggs\zope.publisher-3.4.6-py2.4.egg\zope\publisher\publish.py",
line 108, in mapply
    return debug_call(obj, args)
   - __traceback_info__: <test.app.AddFoo object at 0x02F2B670>
  File
"c:\docume~1\jm\buildo~1\eggs\zope.publisher-3.4.6-py2.4.egg\zope\publisher\publish.py",
line 114, in debug_call
    return obj(*args)
  File
"c:\docume~1\jm\buildo~1\eggs\grokcore.formlib-1.1-py2.4.egg\grokcore\formlib\components.py",
line 90, in __call__
    self.update_form()
  File
"c:\docume~1\jm\buildo~1\eggs\grokcore.formlib-1.1-py2.4.egg\grokcore\formlib\components.py",
line 62, in update_form
    super(GrokForm, self).update()
  File
"c:\docume~1\jm\buildo~1\eggs\zope.formlib-3.4.0-py2.4.egg\zope\formlib\form.py",
line 736, in update
    self.setUpWidgets()
  File
"c:\docume~1\jm\buildo~1\eggs\zope.formlib-3.4.0-py2.4.egg\zope\formlib\form.py",
line 717, in setUpWidgets
    form=self, adapters=self.adapters, ignore_request=ignore_request)
  File
"c:\docume~1\jm\buildo~1\eggs\zope.formlib-3.4.0-py2.4.egg\zope\formlib\form.py",
line 278, in setUpWidgets
    IInputWidget)
  File
"c:\docume~1\jm\buildo~1\eggs\zope.component-3.4.0-py2.4.egg\zope\component\_api.py",
line 103, in getMultiAdapter
    raise ComponentLookupError(objects, interface, name)
ComponentLookupError: ((<zope.schema._bootstrapfields.Field object at
0x02F2B730>, <hurry.zoperesource.zopesupport.Request instance
URL=http://localhost:80
80/test/foos/add>), <InterfaceClass zope.app.form.interfaces.IInputWidget>,
u'')

Am I doing something wrong?
-- 
View this message in context: http://www.nabble.com/Containment-Contraints-tp23152405p23156801.html
Sent from the Grok mailing list archive at Nabble.com.



More information about the Grok-dev mailing list