hide nested classes in a python products -- how?
Hi, I'm re-implementing my nested ZClass product as a python product. The ZClass product contains a class 'portal' which is the only one which should be add-able to any ordinary folder, and a cascade of further classes which can be added inside the portal. In my classes I'm able to restrict the list of contained classes via _allowed_meta_types. But in an ordinary Folder, any object can be added. Is it possible to prevent the further classes to show up in the normal list, so that only 'portal's can be added to a normal Folder object? Or is the only solution to throw an exception? tia, Tobias -- (sorry for any unfriendly footer added automatically against my wishes... please ignore it!) Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das un- erlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
If you're planning on distributing this, the best solution may be to define a "folderish" object that can only contain instances of the products you are defining. In a nutshell, you inherit the characteristics of the built-in Folder object and override the methods you want to behave differently. Once you've done this, you can impose just about any restrictions you wish. If you're not distributing this, it may just be sufficient to restrict add privileges on the folder in question to people who can be trusted to make the correct choices. HTH, Dylan At 07:14 PM 11/11/2002 +0100, you wrote:
Hi,
I'm re-implementing my nested ZClass product as a python product.
The ZClass product contains a class 'portal' which is the only one which should be add-able to any ordinary folder, and a cascade of further classes which can be added inside the portal.
In my classes I'm able to restrict the list of contained classes via _allowed_meta_types. But in an ordinary Folder, any object can be added.
Is it possible to prevent the further classes to show up in the normal list, so that only 'portal's can be added to a normal Folder object? Or is the only solution to throw an exception?
tia,
Tobias -- (sorry for any unfriendly footer added automatically against my wishes... please ignore it!)
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das un- erlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi, --On Montag, 11. November 2002 19:14 +0100 Tobias Herp <THerp@apriori.de> wrote:
Hi,
I'm re-implementing my nested ZClass product as a python product.
The ZClass product contains a class 'portal' which is the only one which should be add-able to any ordinary folder, and a cascade of further classes which can be added inside the portal.
In my classes I'm able to restrict the list of contained classes via _allowed_meta_types. But in an ordinary Folder, any object can be added.
Is it possible to prevent the further classes to show up in the normal list, so that only 'portal's can be added to a normal Folder object? Or is the only solution to throw an exception?
If you only use: from ZClasses import createZClassForBase createZClassForBase( base_class=YourProduct.HiddenBaseClass, pack=globals() , nice_name='YourHiddenBaseClass', meta_type='YourHiddenClass' ) you can derive from your class in ZClasses, but they dont show up in the add list. HTH Tino Wildenhain
Tobias Herp writes:
... Is it possible to prevent the further classes to show up in the normal list, so that only 'portal's can be added to a normal Folder object? Or is the only solution to throw an exception? I see two options:
* you do not register your (subordinate) classes and define the method "all_meta_types" in your top class. "all_meta_types" describes the meta types that can be added to your top class. See "OFS.ObjectManager.ObjectManager.all_meta_types", for details. * you register your (subordinate) classes but use "visibility=None" (I think, it is that name, but I am not sure). You can then access them via the interface, they implement. Look at "PluggableIndexes", for an example. Dieter
participants (4)
-
Dieter Maurer -
Dylan Reinhardt -
Tino Wildenhain -
Tobias Herp