Re: [Zope-dev] REPOST: Cut down on the Available Objects list.

2000-09-07 Thread Jim Fulton

Erik Enge wrote:
> 
> 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.)

You would override the method all_meta_types. See
this method in lib/python/OFS/ObjectManager.py.

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]
Technical Director   (888) 344-4332  Python Powered!
Digital Creationshttp://www.digicool.com http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] REPOST: Cut down on the Available Objects list.

2000-09-07 Thread Brian Lloyd

> 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[EMAIL PROTECTED]
Software Engineer  540.371.6909
Digital Creations  www.digicool.com

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )