throws exception on save when editing a person with custom demographic fields

Bug #783887 reported by dleigh on 2011-05-17
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Douglas Cerna

Bug Description

I've added some demographic fields. One is their network logon. I made it required. I just edited a user who had been imported BEFORE adding these fields. I added their network logon and clicked save. Got the following exception trace:


  InvalidKeyError: ID

  File "/usr/lib/python2.7/dist-packages/zope/publisher/", line 132, in publish
  result = publication.callObject(request, obj)
File "/usr/lib/python2.7/dist-packages/zope/app/publication/", line 207, in callObject
  return mapply(ob, request.getPositionalArguments(), request)
File "/usr/lib/python2.7/dist-packages/zope/publisher/", line 107, in mapply
  return debug_call(obj, args)
Extra information: <zope.browserpage.metaconfigure.PersonEditView object at 0x1194666c>
File "/usr/lib/python2.7/dist-packages/zope/publisher/", line 113, in debug_call
  return obj(*args)
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 215, in __call__
File "/usr/lib/python2.7/dist-packages/schooltool/basicperson/browser/", line 361, in update
  super(PersonEditView, self).update()
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 210, in update
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 99, in execute
  result = handler()
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 311, in __call__
  return handler(self.form, self.action)
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 170, in __call__
  return self.func(form, action)
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 294, in handleApply
  changes = self.applyChanges(data)
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 275, in applyChanges
  changes = applyChanges(self, content, data)
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 52, in applyChanges
File "/usr/lib/python2.7/dist-packages/z3c/form/", line 76, in set
  setattr(self.adapted_context, self.field.__name__, value)
File "/usr/lib/python2.7/dist-packages/schooltool/basicperson/", line 107, in __setattr__
  self.demographics[name] = value
File "/usr/lib/python2.7/dist-packages/schooltool/basicperson/", line 78, in __setitem__
  raise InvalidKeyError(key)

Changed in schooltool:
status: New → Confirmed
Gediminas Paulauskas (menesis) wrote :

Usually this does not happen. I could add, remove custom fields, and everything worked.

One way to reproduce this is:
1. create a second field with Title=whatever, ID=ID
2. try to edit a person, crash (Duplicate name: ID)
3. go to Demographics, remove the first ID.
4. try saving the person again, and you get this InvalidKeyError.

To avoid this issue, delete a field that causes problems. In our test case, it is "whatever", its link ends with "ID-2". Create a new field, but set ID to something else. , e.g. Title=Logon, ID=logon.

The problems are that ID is not checked for uniqueness when creating a field (2), and that ID is used where __name__ should be (4).

dleigh (david-leighweb) wrote :

Thanks. I'll use that as a work-around.

Changed in schooltool:
importance: Undecided → High
Changed in schooltool:
assignee: nobody → Douglas Cerna (replaceafill)
importance: High → Critical
status: Confirmed → Triaged
Changed in schooltool:
milestone: none → 2.0.2
Changed in schooltool:
status: Triaged → In Progress
Changed in schooltool:
milestone: 2.0.2 → 2.0.3
Changed in schooltool:
status: In Progress → Fix Committed
Changed in schooltool:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers