[zopeorg-checkins] CVS: Products/ZopeOrg-NV/Extensions - NZOMigrate.py:1.21

Sidnei da Silva sidnei at x3ng.com.br
Thu Apr 17 15:15:04 EDT 2003


Update of /cvs-zopeorg/Products/ZopeOrg-NV/Extensions
In directory cvs.zope.org:/tmp/cvs-serv7017/Extensions

Modified Files:
	NZOMigrate.py 
Log Message:
partial commit

=== Products/ZopeOrg-NV/Extensions/NZOMigrate.py 1.20 => 1.21 === (2150/2250 lines abridged)
-import sys
-from StringIO import StringIO
-from ZODB.POSException import POSKeyError
-from Acquisition import aq_base, aq_parent, aq_inner
-from Products.CMFCore.utils import getToolByName
-from Products.CMFCollector.CollectorIssue import CollectorIssue
-from DateTime import DateTime
-from DocumentTemplate.DT_HTML import HTML as DTML
-from zExceptions.ExceptionFormatter import format_exception
-import zLOG
-
-def _send_update_notice(self, *args, **kw):
-    pass
-
-def migrate(source, dest, ignore_path=None, type_map=None, exceptions=None):
-    dest_path = dest.getPhysicalPath()
-    if ignore_path is None: ignore_path = []
-    if not dest_path in ignore_path:
-        ignore_path.append(dest_path)
-    ignore_path = [tuple(p.split('/')) for p in ignore_path \
-		   if type(p) == type('')]
-    if type_map is None:
-        type_map = {"Formatted Document" : "CMF Default Document",
-                    "STX Document" : "CMF Default Document",
-                    "HTML Document" : "CMF Default Document",
-                    "Link" : "CMF Default Link",
-                    "News Item": "CMF Default News Item",
-                    "Folder": "CMF Portal Folder",
-                    "Image": "CMF Default Image",
-                    "File": "CMF Default File",
-                    "Tip": "ZopeOrg Tip",
-                    "How-To": "ZopeOrg HowTo",
-                    "Software Product": "CMF Software Package",
-                    "Product Release": "CMF Software Release",
-                    "Tracker": "CMF Collector",
-                    "User Folder": "User Folder",
-                    "Members Folder": "User Folder",
-                    "ZCatalog": "ZCatalog",
-                    "BTree Folder": "CMF BTree Folder",
-                    "ZWiki Page": "ZWiki Page",
-                    "Broken Because Product is Gone": "BBR",
-                    "XML Document": "Parsed XML",
-                    "BackTalk Book": "CMF BackTalk Book",
-                    "BackTalk Document": "CMF BackTalk Document",
-                    "External Method": "Unsafe"
-                    }
-
-        if exceptions is None:
-            exceptions = {}
-            exceptions['Resources/ZSP/zsp.xml'] = 'ZSP2ZopeOrgZSP'

[-=- -=- -=- 2150 lines omitted -=- -=- -=-]

+                        new_obj = copyProperties(obj, new_obj)
+                    except:
+                        self.log(pretty_exc(sys.exc_info()))
+
+                    res = []
+                    try:
+                        res = _cleanupOwnership(new_obj, res, 0)
+                        if res != []:
+                            self.log('\n'.join(res) + '\n')
+                    except:
+                        self.log(pretty_exc(sys.exc_info()))
+
+                    try:
+                        massPublish(new_obj, 0)
+                    except:
+                        self.log(pretty_exc(sys.exc_info()))
+
+                    if hasattr(obj, 'objectIds') and new_obj is not None:
+                        ignore = WikiMethodsCleanup(obj, obj_url, ignore)
+                        ignore = DefaultDTMLCleanup(obj, obj_url, ignore)
+                        self.log(Transmutator(obj, new_obj, \
+                                              ignore, self._type_map, \
+                                              self._exceptions, \
+                                              self._count).run(), dup=0)
+
+                        if source_id == 'Members':
+                            res = recursiveOwnerFix(new_obj, oid, 1)
+                            setLocalRoles(new_obj, (oid, ), 'Owner', obj_url)
+
+                    try:
+                        new_obj = fixModificationDate(obj, new_obj)
+                    except:
+                        self.log(pretty_exc(sys.exc_info()))
+
+                    ct = getToolByName(new_obj, 'portal_catalog', None)
+                    if ct is not None:
+                        try: ct.reindexObject(obj)
+                        except: pass
+
+                    if self._count % 100:
+                        get_transaction().commit()
+                    elif self._count % 50:
+                        get_transaction().commit(1)
+
+                self.log('%s: Success.\n' % obj_url)
+
+        return 'Ok.\n'
+
+if __name__ == '__main__':
+    print 'ok'





More information about the zopeorg-checkins mailing list