[Zope] Python Class trickyness
Andrew Kenneth Milton
akm@mail.theinternet.com.au
Sun, 6 Aug 2000 11:56:40 +1000 (EST)
+----[ Erik Enge ]---------------------------------------------
|
| Good evening.
|
| I know how to make a Python Class, which is a container. But how do
| I make another Class which can only be added from the container-class
| I have created. Know what I mean? The last class should only show up
| in the "Available Objects"-list if the user is in a instance of the
| first class. Did this make any sense?
|
| Thanks for any answers. :-)
This is easier than you might think:-
Step 1: Do not register your 'sub' class(es) in your __init__.py
Step 2: In your container class import your sub class manage_add function(s)
(not sure if this is really needed, but, I do it for completeness).
Step 3: In your container class add:-
meta_types=({'name':'Sub Product', 'action':'manage_addSubProduct'},) # Sub-ob
ject types that are specific to this object
You can add as many as you like...
Step 5: Optionally add a meta_type to your sub class (if you haven't)
Step 6: Optionally add icon='thisIcon.gif" into your sub classes so they get
pretty icons.
Copy over new Product, and Restart Zope :-)
--
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|