[Zope-CMF] Inconsistent CMF Objects, ZMI issue, how to correct/convert objec ts ?

Raphael Ritz r.ritz@biologie.hu-berlin.de
Mon, 10 Mar 2003 09:27:04 +0100


Jean-Francois.Doyon@CCRS.NRCan.gc.ca wrote:

>Hello,
>
>I just tried to upgrade my current 2.5.1+CMF-1.2 to 2.6.1+CMF1.3 ... Without
>success ... For some reason, with some Documents the default view is found,
>but not for others.
>
>After doing some digging, I discovered this may be related to the fact that
>not all CMF objects seem to be equal. Some "Documents" have a document
>looking icon, some don't.
>
>A while ago, someone had mentionned, in one thread or another, that creating
>CMF objects from the ZMI was bad somehow. I think I am now suffering from
>being guilty of doing such things when I didn't know any better (Other than
>the wrong Icon, everything seemed to work ok).
>
>When I started with Zope I wrote a batch loader similar to site_loader.py
>... but in Perl, and for the CMF ... Only I modeled it's behavior after what
>I saw in the ZMI ... I know this was a mistake! But now I'm stuck with
>thousands of "bad" CMF objects it seems.
>
>So, the question now is how do I fix this? Why is the ZMI way of doing
>things wrong, and if it's known to be wrong why is it even there? I'd like
>to better understand this behavior ...
>
Adding an object via ZMI by default calls the object's constructor directly
whereas the proper CMF/Plone way is to use 'invokeFactory'
which takes care of all the add-ons the CMF provides (catalog, workflow 
etc.)
Moreover, calling, e.g., 'invokeFactory('Folder', myfolderid)'  creates 
a portal_folder
which is different from a stock Zope folder (which doesn't provide 
'invokeFactory'
for instance).
In any case I would recommend that you recreate your objects. And I 
wouldn't use
XML import/export but rather more direct ways like FTP or even Pythons 
urllib for
stuff that you have available somewhere else. Objects that you have in ZODB
already don't need to be exported/changed/imported but you can just get them
from within Zope, figure out their metatype and all other properties and 
then create
the appropriate portal object.

HTH,

    Raphael
 
Raphael

>
>Is there a way for me to fix the objects in place? Possibly by exporting as
>XML, editing the XML, and re-importing? (A technique, believe it or not,
>I've used successfully recently :)
>
>I could also write a script that takes ALL objects, create a new object
>PROPERLY, migrates the properties, and renames ... But I want to make sure I
>use the RIGHT methods and everything this time ...
>
>Any help in dealing with this would be greatly appreciated!
>
>Thanks,
>
>Jean-François Doyon
>Internet Service Development and Systems Support / Soutien de systèmes et
>developement de services Internet
>GeoAccess Division / Division GéoAccès
>Canada Center for Remote Sensing / Centre canadien de télédétection
>Natural Resources Canada /  Ressources naturelles Canada
>Phone / Téléphone: (613) 992-4902
>Fax / Télécopieur: (613) 947-2410
>http://atlas.gc.ca
>
>
>_______________________________________________
>Zope-CMF maillist  -  Zope-CMF@zope.org
>http://mail.zope.org/mailman/listinfo/zope-cmf
>
>See http://collector.zope.org/CMF for bug reports and feature requests
>
>  
>