[Zope-CMF] meta_type != content_meta_type

Tres Seaver tseaver@zope.com
Mon, 22 Oct 2001 07:51:19 -0400


seb bacon wrote:

 > * seb bacon <seb@jamkit.com> [011018 18:49]:
 >
 >> Hi,
 >>
 >> When I create a new TypeInformation 'MyFoo', based on an existing class
 >> 'Foo', but with its own meta_type 'My Foo',

This should not ever happen:  'meta_type' is an attribute of the
underlying Python class for a content type, and not of an individual
content type itself.  No code anywhere in the system should ever
overwrite 'meta_type' on an instance, as weird and ugly things will
result.

 >> instances of it do not appear in lists such as contentValues().
 >>
 >> This is because contentValues() passes a list of meta_types
 >> for objectValues() to filter by.  The list passed from contentValues() is
 >> a list of content_meta_types (i.e. 'My Foo'); but objectValues() compares
 >> it to meta_types (i.e. 'Foo').
 >>
 >
 > OK, my solution was to add a new attribute to TypeInformation, base_meta_data,
 >  and a new parameter to listContentTypes, viz:
 >
 > def listContentTypes( self, container=None,
 >                             by_metatype=0,
 >                             by_base_metatype=0  )
 >
 > Then PortalFolder._morphSpec returns a list of base meta_types for use with
 > objectIds.
 >
 > Does this sound OK?

Your 'base_meta_type' is performing *exactly* the function for which
'content_meta_type' was added (what else are you using 'content_meta_type'
for?)  Generally, *don't* change 'content_meta_type', and you won't have
a problem.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com