- ChrisW (20/7)
I don't see the need for the _addableIn function. Why not just have an _addableIn property of the class (is that possible?) that is a list containing the meta_types of object managers that the class can be added in. The ObjectManagerx patch would then become trivial:
if self.meta_type in class_to_be_added.__class__._addableIn:
# code to add it
else:
# die with error
- Itamar (30/7)
I feel that you should be able to limit adding of objects by other parameters as well, e.g. ensuring that one of your ancestors, not just your immediate parent, has a specific meta_type.
Limiting by meta_type of parent is useful of course, but I'd rather not limit the developer's power to develop more sophisticated tests.
- Brian (31/7)
I agree that the interface to whatever we end up implementing
for restricted creation should be a method or set of methods.
In fact, history has proven quite adequately (to me, anyway)
that all interfaces should avoid direct attribute access,
even if using methods doesn't appear to buy you anything
for the immediate goals. Witness the debacle of trying to
figure out the id
of an object from within DTML. :^) Using
methods is future-proofing.
- Jim (Aug 1)
I like this proposal.
It doesn't make sense to define this as a class method, because:
The function should be an optional key, named filter
,
in the meta-type mapping object associated with the constructor.
There should be a filter
argument added to the registerClass
method of ProductContext
objects that would allow this
function to be specified in Python product initialization
code. There should be a filter option added to factories to
allow a method to be provded for factories.