[Zope-dev] REPOST: Cut down on the Available Objects list.
Brian Lloyd
Brian@digicool.com
Thu, 7 Sep 2000 10:39:15 -0400
> Hi, all - someone suggested to me that I should try the zope-dev list
> instead of the zope list, here goes.
>
> When I create ZClasses I can make the Available Objects shrink to just
> a couple of available objects via subclasses and so forth. How would
> I do this with a Python Class in a Python Zope Product? (Let's say an
> OFS.Folder.Folder class, which could normally contain all available
> objects.)
Erik,
In the ObjectManager class (lib/python/OFS/ObjectManager.py),
there is a method 'filtered_meta_types', which is called by
the DTML that implements the Zope management screens. The
job of this method is to filter the list of available objects
based on the authorization of the user.
An approach that you could use is to override that method in
your class so that it only returns the object types that you
want. You should probably retain the filtering based on
authorization for consistency (you could probably just call
the ObjectManager class' method and refilter the result in
your overridden version). For ex:
class MyFolderishObject(ObjectManager):
...
def filtered_meta_types(self, user=None):
# overridden version
result=[]
# get the filtered list from superclass, so things
# that the user isn't authorized for are already
# filtered out...
types=ObjectManager.filtered_meta_types(self, user)
# each meta type is a mapping - the name of the
# object type is under the key 'name'. We'll filter
# out all that start with 'D' as an example.
for item in types:
if item['name'][0] != 'D':
result.append(item)
return result
Hope this helps!
Brian Lloyd brian@digicool.com
Software Engineer 540.371.6909
Digital Creations www.digicool.com