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

Norman Khine khine@btinternet.com
Tue, 31 Jul 2001 07:57:24 +0100


Thanks Tres,
I hope you had a good "break", and seems your in-box is full;^)

Using the external method as described, does it mean, I can modify other
attributes, just by including

 doc = brain.getObject()
       doc.portal_type = 'Card'
---->  doc.review_state = 'published'
       updated.append( doc )

if I want to make all these documents published, for example?

Also, shouldn't portal_type be meta_type, as I am changing the meta_type
from Document to Card?

Regards

Norman


-----Original Message-----
From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf
Of Tres Seaver
Sent: 31 July 2001 05:11
To: Norman Khine
Cc: Zope-CMF
Subject: Re: [Zope-CMF] Is there a way to change the meta-type of a
number of object types


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


_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests