[Zope-CMF] Is there a way to change the meta-type of a number of object types

Tres Seaver tseaver@palladion.com
Tue, 31 Jul 2001 00:11:17 -0400


Norman Khine wrote:

> Hi,
> I have over 300 Documents that are a document type, I have now created a new
> type called Card which is based on the Document type, but this type only has
> a number of Subject topics taken from the original Document type.
> 
> So now I want to take all Documents with the specific topics and make them
> the new Card type.


I *think* that what you are looking for is the 'portal_type' attribute;
content objects use that attribute to find their type objects, which then
give them access to the other type-specific policies.  You should be able
to write an ExternalMethod which queries the catalog for the Documents
you would like to make into Cards, and then just set the attribute.

Something like:

   updated = []
   for brain in self.portal_catalog.searchResults( Type='Document'
                                                 # other criteria here
                                                 ):
       doc = brain.getObject()
       doc.portal_type = 'Card'
       updated.append( doc )

   for doc in updated:
       doc.reindexObject()


> I can create a Topic query which can list these items, but I don't think it
> is possible to change them, or is it?
> 
> Where in the system, does an object stores these detail and can it be
> changed?


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