Stephan,

Thanks again for you help.

I'm still having the ErrorViewSnippet problem.  I've gone over and over the
message example in formdemo and can't see anything different in my setup
from the demo.  The demo works fine but mine throws the ErrorViewSnippet
error when I submit an AddForm with missing input.  EditForm works correct
though.

Here is the full traceback.  I'll also include the browser files at the end.

Traceback (most recent call last):
  Module zope.publisher.publish, line 133, in publish
    result = publication.callObject(request, obj)
  Module zope.app.publication.zopepublication, line 161, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
  Module zope.publisher.publish, line 108, in mapply
    return debug_call(obj, args)
   - __traceback_info__: <security proxied
z3c.pagelet.zcml.RestaurantAddForm instance at 0x033DE610>
  Module zope.publisher.publish, line 114, in debug_call
    return obj(*args)
  Module z3c.formui.layout, line 40, in __call__
    return layout(self)
  Module zope.app.pagetemplate.viewpagetemplatefile, line 51, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations)()
  Module zope.tal.talinterpreter, line 271, in __call__
    self.interpret(self.program)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 534, in do_optTag_tal
    self.no_tag(stuff[-2], stuff[-1])
  Module zope.tal.talinterpreter, line 516, in no_tag
    self.interpret(program)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
    structure = self.engine.evaluateStructure(expr)
  Module zope.tales.tales, line 696, in evaluate
    return expression(self)
   - D:\Mats\Zope\lib\python\metrod\app\skin\template.pt
   - Line 22, Column 2
   - Expression: <StringExpr u'pagelet'>
   - Names:
      {'args': (),
       'context': <zope.app.folder.folder.Folder object at 0x01B80BF0>,
       'default': <object object at 0x0099C568>,
       'loop': {},
       'nothing': None,
       'options': {},
       'repeat': {},
       'request': <zc.resourcelibrary.publication.Request instance
URL=http://localhost:50080/++skin++MetroDSkin/@@addRestaurant.html>,
       'template':
<zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile object at
0x023361F0>,
       'usage': <zope.pagetemplate.pagetemplate.TemplateUsage object at
0x033DE8D0>,
       'view': <z3c.pagelet.zcml.RestaurantAddForm object at 0x033DE610>,
       'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper
object at 0x033DE4F0>}
  Module zope.contentprovider.tales, line 74, in __call__
    return provider.render()
  Module z3c.pagelet.provider, line 43, in render
    return self.__parent__.render()
  Module z3c.form.form, line 186, in render
    return super(AddForm, self).render()
  Module z3c.form.form, line 95, in render
    return template(self)
  Module zope.app.pagetemplate.viewpagetemplatefile, line 51, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations)()
  Module zope.tal.talinterpreter, line 271, in __call__
    self.interpret(self.program)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 891, in do_useMacro
    self.interpret(macro)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
    self.interpret(block)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
    self.interpret(macro)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
    self.do_optTag(stuff)
  Module zope.tal.talinterpreter, line 521, in do_optTag
    return self.no_tag(start, program)
  Module zope.tal.talinterpreter, line 516, in no_tag
    self.interpret(program)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 855, in do_condition
    self.interpret(block)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 855, in do_condition
    self.interpret(block)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 824, in do_loop_tal
    self.interpret(block)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 534, in do_optTag_tal
    self.no_tag(stuff[-2], stuff[-1])
  Module zope.tal.talinterpreter, line 516, in no_tag
    self.interpret(program)
  Module zope.tal.talinterpreter, line 346, in interpret
    handlers[opcode](self, args)
  Module zope.tal.talinterpreter, line 623, in do_insertText_tal
    text = self.engine.evaluateText(stuff[0])
  Module zope.tales.tales, line 704, in evaluateText
    text = self.evaluate(expr)
  Module zope.tales.tales, line 696, in evaluate
    return expression(self)
   - C:\Python24\Lib\site-packages\z3c\formui\div-form.pt
   - Line 22, Column 10
   - Expression: <PathExpr standard:u'error/widget/label'>
   - Names:
      {'args': (),
       'context': <zope.app.folder.folder.Folder object at 0x01B80BF0>,
       'default': <object object at 0x0099C568>,
       'loop': {},
       'nothing': None,
       'options': {},
       'repeat': {},
       'request': <zc.resourcelibrary.publication.Request instance
URL=http://localhost:50080/++skin++MetroDSkin/@@addRestaurant.html>,
       'template':
<zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile object at
0x0234E9F0>,
       'usage': <zope.pagetemplate.pagetemplate.TemplateUsage object at
0x033DEC90>,
       'view': <z3c.pagelet.zcml.RestaurantAddForm object at 0x033DE610>,
       'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper
object at 0x033DEBD0>}
  Module zope.tales.expressions, line 217, in __call__
    return self._eval(econtext)
  Module zope.tales.expressions, line 194, in _eval
    ob = self._subexprs[-1](econtext)
  Module zope.tales.expressions, line 124, in _eval
    ob = self._traverser(ob, element, econtext)
  Module zope.app.pagetemplate.engine, line 68, in __call__
    request=request)
  Module zope.traversing.adapters, line 164, in traversePathElement
    return traversable.traverse(nm, further_path)
   - __traceback_info__: (<ErrorViewSnippet for RequiredMissing>, 'widget')
  Module zope.traversing.adapters, line 52, in traverse
    raise TraversalError(subject, name)
   - __traceback_info__: (<ErrorViewSnippet for RequiredMissing>, 'widget',
['label'])
TraversalError: (<ErrorViewSnippet for RequiredMissing>, 'widget') 

browser/restaurant.py

from metrod.restaurant.restaurant import Restaurant
from metrod.restaurant.interfaces import IRestaurant
from zope.app.container.interfaces import INameChooser
from zope.traversing.browser import absoluteURL
from z3c.formui import layout

from z3c.form import field, form


class RestaurantAddForm(layout.AddFormLayoutSupport, form.AddForm):
    fields = field.Fields(IRestaurant)
    template = None
    layout = None
    contentName = None
    label = u'Add Form'
    
    def create(self, data):
        r = Restaurant()
        r.name = data['name']
        r.description = data['description']
        return r
        
    def add(self, object):
        nc = INameChooser(self.context)
        self._name = nc.chooseName(object.name, object)
        if not nc.checkName(self._name, object):
                raise ValueError("PROBLEM")
        self.context[self._name] = object
        return object
    
    def nextURL(self):
        return absoluteURL(self.context[self._name], self.request)

class RestaurantEditForm(layout.FormLayoutSupport, form.EditForm):
    fields = field.Fields(IRestaurant)

browser/restaurant.pt

<div metal:use-macro="macro:form" />

browser/configure.zcml

<configure
  xmlns="http://namespaces.zope.org/browser";
  xmlns:z3c="http://namespaces.zope.org/z3c";>

  <z3c:pagelet
    name="addRestaurant.html"
    for="zope.app.container.interfaces.IContainer"
    class=".restaurant.RestaurantAddForm"
    layer="metrod.app.layer.IMetroDBrowserLayer"
    permission="zope.Public" />
    
  <z3c:template
    template="restaurant.pt"
    for=".restaurant.RestaurantAddForm"
    layer="metrod.app.layer.IMetroDBrowserLayer" />

  <z3c:pagelet
    name="index.html"
    for="metrod.restaurant.interfaces.IRestaurant"
    class=".restaurant.RestaurantEditForm"
    layer="metrod.app.layer.IMetroDBrowserLayer"
    permission="zope.Public" />
    
  <z3c:template
    template="restaurant.pt"
    for=".restaurant.RestaurantEditForm"
    layer="metrod.app.layer.IMetroDBrowserLayer" />

</configure>


> > Perhaps unrelated but I had this working before. I'm using formui and
> I'm
> > getting a "TraversalError: (<ErrorViewSnippet for RequiredMissing>,
> > 'widget')".  I tried to trim out all the sub-form stuff I've messed
> around
> > with and replaced a simple object with two textlines one of which is
> > required.  This happens when I'm submitting the form without an entry in
> > required field.  With data it works just fine and adds the object.  The
> > addform is using the macro:form from formui.  Any ideas as to where this
> > comes from and how I can fix it?
> 
> No idea. Could you provide the complete traceback?
> 
> Regards,
> Stephan
> --
> Stephan Richter
> CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
> Web2k - Web Software Design, Development and Training

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

Reply via email to