[Grok-dev] Question re EditForm and ZPT

Kathy Manwaring kathy at perfectnotes.com.au
Mon Nov 23 02:32:06 EST 2009


I have created a ZPT which has the following button present:
<input type="submit" id="SubmitButton" name="SubmitButton" value="Save"
class="button" />

The relevant class has an update method that is triggered by the button:
class Edit(grok.EditForm):
    grok.context(Person)
    template = grok.PageTemplateFile('people_templates/edit.pt')

    def update(self, SubmitButton=None, **data):
        # Check if the submit button was clicked.
        if SubmitButton == None:
            print 'SubmitButton empty'
        if SubmitButton != None:
            print 'SubmitButton is:' + SubmitButton + ':'
        if SubmitButton == 'Save':
            print 'you hit the Save button'
            # copy the new or updated information
            print self.context
            print self
            self.applyData(self.context, **data)
            print 'have set fields'

Error: AttributeError: 'Edit' object has no attribute 'adapters'

Information using debug.ini:

URL: http://localhost:8080/my%20system/people/entryValue/edit
Module paste.evalexception.middleware:306 in respond
<<          try:
                __traceback_supplement__ = errormiddleware.Supplement,
self, environ
                app_iter = self.application(environ, detect_start_response)
                try:
                    return_iter = list(app_iter)>>  app_iter =
self.application(environ, detect_start_response)
Module paste.translogger:68 in __call__
<<              self.write_log(environ, method, req_uri, start, status,
bytes)
                return start_response(status, headers)
            return self.application(environ, replacement_start_response)

        def write_log(self, environ, method, req_uri, start, status,
bytes):>>  return self.application(environ,
replacement_start_response)
Module zope.app.wsgi:55 in __call__
<<          handle_errors = environ.get('wsgi.handleErrors', True)

            request = publish(request, handle_errors=handle_errors)
            response = request.response>>  request = publish(request,
handle_errors=handle_errors)
Module zope.publisher.publish:133 in publish
<<                              publication.afterTraversal(request, obj)

                                result = publication.callObject(request, obj)
                                response = request.response
                                if result is not response:>>  result =
publication.callObject(request, obj)
Module grok.publication:89 in callObject
<<          if checker is not None:
                checker.check(ob, '__call__')
            return super(ZopePublicationSansProxy,
self).callObject(request, ob)>>  return
super(ZopePublicationSansProxy, self).callObject(request, ob)
Module zope.app.publication.zopepublication:167 in callObject
<<
        def callObject(self, request, ob):
            return mapply(ob, request.getPositionalArguments(), request)

        def afterCall(self, request, ob):>>  return mapply(ob,
request.getPositionalArguments(), request)

<test.person.Edit object at 0x0313DB30>


Module zope.publisher.publish:108 in mapply
<<
        if __debug__:
            return debug_call(obj, args)

        return obj(*args)>>  return debug_call(obj, args)
Module zope.publisher.publish:114 in debug_call
<<  def debug_call(obj, args):
        # The presence of this function allows us to set a pdb breakpoint
        return obj(*args)

    def publish(request, handle_errors=True):>>  return obj(*args)
Module grokcore.formlib.components:84 in __call__
<<
        def __call__(self):
            mapply(self.update, (), self.request)
            if self.request.response.getStatus() in (302, 303):
                # A redirect was triggered somewhere in update().  Don't
    >>  mapply(self.update, (), self.request)

<bound method Edit.update of <test.person.Edit object at 0x0313DB30>>


Module zope.publisher.publish:108 in mapply
<<
        if __debug__:
            return debug_call(obj, args)

        return obj(*args)>>  return debug_call(obj, args)
Module zope.publisher.publish:114 in debug_call
<<  def debug_call(obj, args):
        # The presence of this function allows us to set a pdb breakpoint
        return obj(*args)

    def publish(request, handle_errors=True):>>  return obj(*args)
Module test.person:127 in update
<<              print self
                #self.adapters = []
                self.applyData(self.context, **data)
                print 'have set fields'
                # if this is a new entry, it will have 'tempentry' as part
of the last name
    >>  self.applyData(self.context, **data)
Module grokcore.formlib.components:128 in applyData
<<      def applyData(self, obj, **data):
            return formlib.apply_data_event(obj, self.form_fields, data,
                                            self.adapters, update=True)

        # BBB -- to be removed in June 2007
    >>  self.adapters, update=True)
AttributeError: 'Edit' object has no attribute 'adapters'

As this is just a button, and it's defined based on EditForm, why does
applyData give an error?

Hoping someone can help, as this really has me stumped - all the
documentation says that I've done it right...

Kathy



More information about the Grok-dev mailing list