Make a Python Products Add list show only certain meta types?
I have a custom Python class (Container) which uses Folder as it's base class. I also have a custom Python class (AnObject). I want it so that when you view a Container object, "AnObject" will be the only meta_type available to be added in the Add List. The problem is that since Container inherits from Folder, the Add List makes all object types available to be added. Is there any way to tell a class to show only certain meta_types? Kevin
Kevin Howe wrote:
I have a custom Python class (Container) which uses Folder as it's base class. I also have a custom Python class (AnObject). I want it so that when you view a Container object, "AnObject" will be the only meta_type available to be added in the Add List. The problem is that since Container inherits from Folder, the Add List makes all object types available to be added. Is there any way to tell a class to show only certain meta_types?
Kevin
There is more than one way. The proper way would probably to be adjust the security settings on your class in python (filtered_metatypes?). The easier way is to just to just write an HTMLFile dtml page to overide manage_main which is what gets called for contents. You can use the original as inspiration its at /OFS/main.dtml. An advantage of this is you can add custom stuff to your contents page based on the context of your product. Kapil
+----[ Kapil Thangavelu ]--------------------------------------------- | Kevin Howe wrote: | > | > I have a custom Python class (Container) which uses Folder as it's base | > class. I also have a custom Python class (AnObject). I want it so that when | > you view a Container object, "AnObject" will be the only meta_type available | > to be added in the Add List. The problem is that since Container inherits | > from Folder, the Add List makes all object types available to be added. Is | > there any way to tell a class to show only certain meta_types? | > | > Kevin | > | | There is more than one way. The proper way would probably to be adjust | the security settings on your class in python (filtered_metatypes?). The simplest way is to; all_meta_types=meta_types=({'name':'Sub Object1', 'action':'manage_addSubObject1Form',}, {'name':'Sub Object2', 'action':'manage_addObject2Form',},) In your 'base' product. If you don't register your sub objects in __init__.py you will also need to import their 'constructors' into your base class, and explictly declare the icon under misc_ -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
participants (3)
-
Andrew Kenneth Milton -
Kapil Thangavelu -
Kevin Howe