I've spend entirely too much time tracking down why I got a KeyError
when the catalog was updating the metadata for an object. After
suspecting bugs in the catalog, acquisition, persistent schema
attributes and several other interesting but innocent parts of out
stack I finally found the problem: good old class inheritence does
not mix well with Archetypes.
What happens that I have a archetype (lets call it Yacht)) which is
derived from another another archetype (called Boat):
class Boat(BaseContent):
schema = BoatSchema
class Yacht(Boat):
schema = BoatSchema.copy() + SailingSchema
for various historic reasons at some point an extra field 'motor' was
monkeypatched into Boat.schema, generateMethods was called to generate
an accessor and a catalog column for getMoter was added. The result is
quite interesting: the catalog aborts with KeyError when it tries to
index a yacht instance.
What happens is that Archetypes generates a getMotor accessor method
for the Boat type. Since Yacht is a derived class it inherits that
method. But since 'motor' is not in the schema for Yacht it accessor
can not find the correct field and generates a KeyError.
In other words there is an implicit rule for Archetypes: a derived
type must always have all fields its base classes have.
I can't decide if this is a bug in Archetypes or not. At least it
was unexpected for me. I can't come up with a change in AT behaviour
that would improve things though.
Wichert.
--
Wichert Akkerman <
wichert@...> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
Plone-developers mailing list
Plone-developers@...
https://lists.sourceforge.net/lists/listinfo/plone-developers