schooltool-developers team mailing list archive
-
schooltool-developers team
-
Mailing list archive
-
Message #00327
(Non?)Persistent scores in the gradebook refactoring
Justas:
I tested the score refactoring branch (lp:~replaceafill/schooltool.gradebook/score_refactoring) with an old database to test how the new implementation affected existing objects.
When I get to a gradebook with existing evaluations I get the traceback below. I googled for the error and it seems like everybody had it when they changed an existing class to inherit from Persistent. I couldn't find a solution, other than evolution :(
If I change the new Score class to inherit from 'object' instead of Persistent everything seems to work. I get no traceback, and the scores are saved, even after I restart the server.
Also, I noticed that requirement.evaluation.Evaluation objects are not persistent anyway in trunk, I think they get persisted through the requirement.evaluation.Evaluations class, which is persistent.
I definitely think the score refactoring is the way to go with gradebook. But, should we evolve every existing Evaluation object (which scares me a little!) or can we continue storing non-persistent objects with the new Score+Evaluation approach?
Let me know your thoughts on this :)
Douglas
PS: I also implemented a "fragile|weak|base on lot of ifs|sucky" helper to print the gradebook as we discussed during the sprint. But it definitely helps a lot when you read the ftests of the gradebook (http://bazaar.launchpad.net/~replaceafill/schooltool.gradebook/score_refactoring/revision/257). I was able to remove a lot of XPath and now I'd like to have similar helpers for testing the dropdowns in the gradebook (Term, Section, due date), for the mygrades view, for the grade activity view and for the grade student view :)
"... allí es cuando te das cuenta que las cosas malas pueden resultar bastante buenas..." - Lionel Messi
Por favor, evite enviarme adjuntos de Word, Excel o PowerPoint.
Vea http://www.gnu.org/philosophy/no-word-attachments.es.html
--------- %< ---------
2011-02-28 00:30:13,876 Couldn't load state for 0x0209
Traceback (most recent call last):
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/ZODB3-3.9.7-py2.6-linux-x86_64.egg/ZODB/Connection.py", line 851, in setstate
self._setstate(obj)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/ZODB3-3.9.7-py2.6-linux-x86_64.egg/ZODB/Connection.py", line 919, in _setstate
self._reader.setGhostState(obj, p)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/ZODB3-3.9.7-py2.6-linux-x86_64.egg/ZODB/serialize.py", line 629, in setGhostState
state = self.getState(pickle)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/ZODB3-3.9.7-py2.6-linux-x86_64.egg/ZODB/serialize.py", line 622, in getState
return unpickler.load()
File "/home/replaceafill/.sandboxes/score_refactoring_254/python/lib/python2.6/copy_reg.py", line 48, in _reconstructor
obj = object.__new__(cls)
TypeError: ('object.__new__(Evaluation) is not safe, use persistent.Persistent.__new__()', <function _reconstructor at 0x21bb320>, (<class 'schooltool.requirement.evaluation.Evaluation'>, <type 'object'>, None))
2011-02-28 00:30:14,123 http://localhost:7080/schoolyears/2010/semester-one/sections/1/activities/Worksheet/gradebook/index.html
Traceback (most recent call last):
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.publisher-3.12.6-py2.6.egg/zope/publisher/publish.py", line 132, in publish
result = publication.callObject(request, obj)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.app.publication-3.12.0-py2.6.egg/zope/app/publication/zopepublication.py", line 207, in callObject
return mapply(ob, request.getPositionalArguments(), request)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.publisher-3.12.6-py2.6.egg/zope/publisher/publish.py", line 107, in mapply
return debug_call(obj, args)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.publisher-3.12.6-py2.6.egg/zope/publisher/publish.py", line 113, in debug_call
return obj(*args)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.browserpage-3.12.2-py2.6.egg/zope/browserpage/simpleviewclass.py", line 44, in __call__
return self.index(*args, **kw)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.browserpage-3.12.2-py2.6.egg/zope/browserpage/viewpagetemplatefile.py", line 83, in __call__
return self.im_func(im_self, *args, **kw)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.browserpage-3.12.2-py2.6.egg/zope/browserpage/viewpagetemplatefile.py", line 51, in __call__
sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.pagetemplate-3.5.2-py2.6.egg/zope/pagetemplate/pagetemplate.py", line 113, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 271, in __call__
self.interpret(self.program)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 343, in interpret
handlers[opcode](self, args)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 888, in do_useMacro
self.interpret(macro)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 343, in interpret
handlers[opcode](self, args)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 533, in do_optTag_tal
self.do_optTag(stuff)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 518, in do_optTag
return self.no_tag(start, program)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 513, in no_tag
self.interpret(program)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 343, in interpret
handlers[opcode](self, args)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 946, in do_defineSlot
self.interpret(slot)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 343, in interpret
handlers[opcode](self, args)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 533, in do_optTag_tal
self.do_optTag(stuff)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 518, in do_optTag
return self.no_tag(start, program)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 513, in no_tag
self.interpret(program)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 343, in interpret
handlers[opcode](self, args)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 819, in do_loop_tal
iterator = self.engine.setRepeat(name, expr)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tales-3.5.1-py2.6.egg/zope/tales/tales.py", line 682, in setRepeat
expr = self.evaluate(expr)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tales-3.5.1-py2.6.egg/zope/tales/tales.py", line 696, in evaluate
return expression(self)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tales-3.5.1-py2.6.egg/zope/tales/expressions.py", line 217, in __call__
return self._eval(econtext)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/zope.tales-3.5.1-py2.6.egg/zope/tales/expressions.py", line 211, in _eval
return ob()
File "/home/replaceafill/.sandboxes/score_refactoring_254/src/schooltool/gradebook/browser/gradebook.py", line 568, in table
value = self.getStudentActivityValue(student, activity)
File "/home/replaceafill/.sandboxes/score_refactoring_254/src/schooltool/gradebook/browser/gradebook.py", line 544, in getStudentActivityValue
value, ss = gradebook.getEvaluation(student, activity)
File "/home/replaceafill/.sandboxes/score_refactoring_254/src/schooltool/gradebook/gradebook.py", line 214, in getEvaluation
ev = evaluations.get(activity, None)
File "/home/replaceafill/.sandboxes/score_refactoring_254/src/schooltool/requirement/evaluation.py", line 97, in get
return self[key]
File "/home/replaceafill/.sandboxes/score_refactoring_254/src/schooltool/requirement/evaluation.py", line 79, in __getitem__
return self._btree[IKeyReference(key)]
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/ZODB3-3.9.7-py2.6-linux-x86_64.egg/ZODB/Connection.py", line 851, in setstate
self._setstate(obj)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/ZODB3-3.9.7-py2.6-linux-x86_64.egg/ZODB/Connection.py", line 919, in _setstate
self._reader.setGhostState(obj, p)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/ZODB3-3.9.7-py2.6-linux-x86_64.egg/ZODB/serialize.py", line 629, in setGhostState
state = self.getState(pickle)
File "/home/replaceafill/.sandboxes/score_refactoring_254/eggs/ZODB3-3.9.7-py2.6-linux-x86_64.egg/ZODB/serialize.py", line 622, in getState
return unpickler.load()
File "/home/replaceafill/.sandboxes/score_refactoring_254/python/lib/python2.6/copy_reg.py", line 48, in _reconstructor
obj = object.__new__(cls)
TypeError: ('object.__new__(Evaluation) is not safe, use persistent.Persistent.__new__()', <function _reconstructor at 0x21bb320>, (<class 'schooltool.requirement.evaluation.Evaluation'>, <type 'object'>, None))
--------- %< ---------