Proposals Table of Contents | Last edited by bavarian on Jul 19, 2001 8:30 pm |
|
Itamar S.T. (itamar@maxnm.NOSPAMcomx)
This proposal is still in a state of flux - add your comments at RestrictedCreationDiscussion.
certain types of objects should not be added except in certain places or with certain restrictions. For example, we may want to make sure Book objects are only added inside Library objects, and nowhere else. Or we may want to make sure that an object is added only if there's a MailHost in it's acquistion path. How do we ensure this?
I propose a Restricted Creation Interface - when an ObjectManagerx constructs it's Add list, it first checks with each class if it's instances can be added in this specific ObjectManagerx.
We do this by calling a class method called _addableIn()
, that receives as a parameter the ObjectManagerx to which we may want to add objects. If the result is not true, instances of this class can't be added, and won't be listed in the Add list.
For example, the following code will only allow this class to be added inside objects whose meta_type is "Librarian":
class Banana: """ Ook Ook Ook """ def _addableIn(parent): if parent.meta_type == "Librarian": return 1 else: return 0
We're calling other people's code every time we view the management interface. This can slow things down, and might be a security risk, especially in ZClasses that are developed throught the web (Python Products are insecure by definition.)
Err, donno.
A patch to ObjectManagerx (to the filtered_meta_types function or some such) which adds a check for objects that can be added.
API Documentation.
A mixin class for ZClasses that's lets them restrict their containers to certain meta_types - equivalent to ObjectManagerx ZClasses ability to restrict their containees by meta_type.
I think the approach of OrderedFolderx is more straightforward: It lets you limit the sub-objects of the Folder like ZClasses with object manager do. IMHO this covers most of the ground ...
© 2000, Digital Creations, Inc. All rights reserved.