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

Bug #783887 reported by dleigh
4
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SchoolTool
Fix Released
Critical
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:

Exception

  InvalidKeyError: ID
Trace

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

Changed in schooltool:
status: New → Confirmed
Revision history for this message
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).

Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.