[ZCM] [ZC] 211/ 1 Request "ZClasses: Object Manager - Inherit Subobjects"
Collector: Zope Bugs and Patches ...
zope-coders@zope.org
Sun, 10 Feb 2002 01:36:38 -0500
Issue #211 Update (Request) "ZClasses: Object Manager - Inherit Subobjects"
Status Pending, Zope/feature+solution medium
To followup, visit:
http://collector.zope.org/Zope/211
==============================================================
= Request - Entry #1 by Anonymous User on Feb 10, 2002 1:36 am
When a ZClass subclasses another ZClass that itself subclasses ZClasses: ObjectManager, it first inherits the meta_types attribute (list of valid subobjects) from its base ZClass. Once changes to the subobjects ZClass management tab have been saved, however, its not possible to allow meat_types to be inherited once again.
I modified ZClasses/dtml/subobjects.dtml to add a radio button to select between inherited meta_types or to use the multiple selection form element on that page. I also modified the multiple selection form element to display the inherited valid subobjects as selected in the list when inherit is selected. Then I modified ZClasses/ObjectManager.py to accomodate all this, primarily by calling delClassAttr('meta_types') when appropriate.
Please let me know what comes of this because if its not incorporated, I need to move the code changes into my python base classes (yuck!) so that I can update my installation without worry. Also, I'm sorry if I've gotten any of the procedure here wrong, this is my first time submitting a patch.
Below are diffs from the old files to the new files (no account and addFile doesn't allow the anonymous user to upload) :
diff ObjectManager.py.bak ObjectManager.py
28c28,31
< return map(lambda v: v['name'], self.getClassAttr('meta_types',()))
---
> if self.inheritSubobjects():
> return map(lambda v: v['name'], self.getClassAttr('meta_types',(), 1))
> else:
> return map(lambda v: v['name'], self.getClassAttr('meta_types',()))
30c33
< def manage_edit(self, meta_types=(), isFolderish=None, REQUEST=None):
---
> def manage_edit(self, inherit=None, meta_types=(), isFolderish=None, REQUEST=None):
32,35c35,42
< self.setClassAttr('meta_types', filter(
< lambda d, m=meta_types: d['name'] in m,
< self.possible_meta_types()
< ))
---
> if inherit:
> if not self.inheritSubobjects():
> self.delClassAttr('meta_types')
> else:
> self.setClassAttr('meta_types', filter(
> lambda d, m=meta_types: d['name'] in m,
> self.possible_meta_types()
> ))
44a52,59
>
> def inheritSubobjects(self):
> try:
> self.getClassAttr('meta_types')
> except KeyError:
> return not 0
> else:
> return not 1
diff dtml/subobjects.dtml.bak dtml/subobjects.dtml.bak
19a20,28
> <tr><td colspan=2>
> <div class="form-label">
> <input type=radio name=inherit value="Y"
> <dtml-if inheritSubobjects>CHECKED</dtml-if>
> >
> Inherit subobjects from bases
> </div>
> </td>
> </tr>
22a32,34
> <input type=radio name=inherit value=""
> <dtml-unless inheritSubobjects>CHECKED</dtml-unless>
> >
==============================================================