[PyPerSyst-Devel] Fwd: sandbox/gldnspud/fieldproblem ...
Brought to you by:
pobrien
|
From: Matthew S. <gld...@us...> - 2004-06-21 17:12:34
|
def testFieldBuilder(self):
db = self.db
b = db.root._classes['Field'].txb_create()
b.new.name = 'foo'
db.execute(b.transaction())
The result of this test is as follows:
ERROR: testFieldBuilder (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test.py", line 23, in testFieldBuilder
b = db.root._classes['Field'].txb_create()
File "/home/gldnspud/p/PYTHONPATH/pypersyst/entity/entity.py", line
179, in txb_create
new = cls._SurrogateClass(attrs={})
File "/home/gldnspud/p/PYTHONPATH/pypersyst/entity/base.py", line 21,
in __init__
value = attrs[name]
KeyError: 'name'
I haven't thought through a solution to this yet, but here is my
understanding of the symptoms.
When a surrogate is created using the txb_create classmethod of an
entity class, the class returned by cls._SurrogateClass is a subclass of
pypersyst.entity.base.Entity
If a _fieldSpec is specified for the Entity class upon which the
surrogate is being created for, ...base.Entity.__init__ iterates through
all of the _fieldSpec items and tries to create field instances for
them, initializing them with the values passed in via the "attrs" argument.
The problem is though, with the surrogate created by txb_create, an
empty dictionary is passed in as "attrs", thus causing the KeyError
exception above.
I think I have a general idea of how to solve this problem based on what
I've done for 'Syst-o-matic so I will post a patch to fix this sometime
today.
|