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

Sidnei da Silva sidnei at x3ng.com.br
Sat May 31 18:21:22 EDT 2003


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

Modified Files:
	NZOMigrate.py 
Log Message:
More migration fixes

=== Products/ZopeOrg-NV/Extensions/NZOMigrate.py 1.26 => 1.27 ===
 def _send_update_notice(self, *args, **kw):
     pass
 
-def migrate(source, dest, ignore_path=None, type_map=None, exceptions=None):
+def migrate(source, dest, ignore_path=None, type_map=None, exceptions=None, debug=0):
     dest_path = dest.getPhysicalPath()
     if ignore_path is None:
         migrate = ['About','CVS','DevHome','DocProjects','Documentation', 'Download', 'Images',\
                    'PTK', 'Products', 'Register', 'Resources', 'SpotlightOn', 'Support', 'Tour',\
                    'Tracker', 'Utilities', 'WikiCentral', 'projects', 'CatalogHelp', 'Help', \
-                   'SiteAnnouncement', 'WhatIsZope', 'ZopeArchitecture', 'ZopeNews', 'privacy.html']
-        members_ignore = ['epson', 'ltunes', 'michel', 'superuser', 'myUnreviewed', 'mail_password_form', \
-                          'mail_password_template', 'password_html', 'tim.kidder', 'update_html', \
-                          'index_html']
+                   'SiteAnnouncement', 'WhatIsZope', 'ZopeArchitecture', 'ZopeNews', 'privacy.html',
+                   'Members']
         ignore_path = ['/%s' % o for o in source.objectIds() if o not in migrate]
-        dont_migrate = ['/Members/%s' % o for o in members_ignore]
-        ignore_path.extend(dont_migrate)
-        if exceptions is None:
-            exceptions = {}
-        cs = source.Resources.CaseStudies
-        for ob in cs.objectValues():
-            if ob.meta_type == 'Folder':
-                exceptions['%s/index_html' % ob.absolute_url(relative=1)] = 'CaseStudies2ZopeOrgCaseStudies'
-                for subob in ob.objectValues():
-                    if subob.meta_type != 'Image' and subob.getId() != 'index_html':
-                        ignore_path.append('/%s' % subob.absolute_url(relative=1))
-
+    members_ignore = ['billqian', 'edward', 'epson', 'ltunes', 'michel', 'superuser', \
+                      'myUnreviewed', 'mail_password_form', \
+                      'mail_password_template', 'password_html', 'tim.kidder', 'update_html', \
+                      'index_html']
+    dont_migrate = ['/Members/%s' % o for o in members_ignore]
+    ignore_path.extend(dont_migrate)
+    if exceptions is None:
+        exceptions = {}
+    cs = source.Resources.CaseStudies
+    for ob in cs.objectValues():
+        if ob.meta_type == 'Folder':
+            exceptions['%s/index_html' % ob.absolute_url(relative=1)] = 'CaseStudies2ZopeOrgCaseStudies'
+            for subob in ob.objectValues():
+                if subob.meta_type != 'Image' and subob.getId() != 'index_html':
+                    ignore_path.append('/%s' % subob.absolute_url(relative=1))
     if not dest_path in ignore_path:
         ignore_path.append(dest_path)
     ignore_path = [tuple(p.split('/')) for p in ignore_path \
@@ -69,7 +70,7 @@
         if not 'Resources/ZSP/zsp.xml' in exceptions.keys():
             exceptions['Resources/ZSP/zsp.xml'] = 'ZSP2ZopeOrgZSP'
 
-    tmut = Transmutator(source, dest, ignore_path, type_map, exceptions)
+    tmut = Transmutator(source, dest, ignore_path, type_map, exceptions, debug=debug)
     tmut.log('Migration script started at %s.\n' % DateTime().ISO())
     result = tmut.run()
     tmut.log('Migration script finished at %s.\n' % DateTime().ISO())
@@ -629,7 +630,7 @@
 
 class Transmutator:
 
-    def __init__(self, source, dest, ignore_path, type_map, exceptions, count=0):
+    def __init__(self, source, dest, ignore_path, type_map, exceptions, count=0, debug=0):
         self._source = source
         self._dest = dest
         self._ignore_path = ignore_path
@@ -637,6 +638,7 @@
         self._count = count
         self._exceptions = exceptions
         self._out = StringIO()
+        self._debug = debug
 
     def log(self, message, summary='', severity=0, dup=1):
         self._out.write(message)
@@ -1133,6 +1135,11 @@
         dest = self._dest
         ignore = self._ignore_path
         source_id = source.getId()
+        if not hasattr(aq_base(dest), 'meta_type') or \
+               not hasattr(aq_base(dest), 'objectIds'):
+            # maybe-not-object. eg: we acquired the 'view' method
+            self.log('Destination is invalid. %r \n' % dest)
+            return 'Ok.\n'
         if hasattr(source, 'objectIds') and \
                hasattr(source, 'getPhysicalPath'):
             path = source.getPhysicalPath()
@@ -1164,6 +1171,10 @@
 
                 mm = self.getMigrationMethod(obj, obj_url)
 
+                if self._debug:
+                    import pdb
+                    pdb.set_trace()
+                
                 try:
                     __traceback_info__ = (obj_url, obj.__class__.__name__, obj, source, dest)
                     new_objs = mm(obj, source, dest)
@@ -1218,11 +1229,11 @@
                         self.log(Transmutator(obj, new_obj, \
                                               ignore, self._type_map, \
                                               self._exceptions, \
-                                              self._count).run(), dup=0)
+                                              self._count, debug=self._debug).run(), dup=0)
 
-                        if source_id == 'Members':
-                            res = recursiveOwnerFix(new_obj, oid, 1)
-                            setLocalRoles(new_obj, (oid, ), 'Owner', obj_url)
+                        #if source_id == 'Members':
+                        #    res = recursiveOwnerFix(new_obj, oid, 1)
+                        #    setLocalRoles(new_obj, (oid, ), 'Owner', obj_url)
 
                     try:
                         new_obj = fixModificationDate(obj, new_obj)





More information about the zopeorg-checkins mailing list