Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
migrate_ptk.Migrator Class Reference

List of all members.

Public Member Functions

def __init__
def migrateObjectManager
def migrateDiscussionContainer
def migratePossibleContainer
def migrateObject

Public Attributes

 conversions
 skip
 visited_folders
 warnings
 copied
 skipped

Detailed Description

Definition at line 17 of file migrate_ptk.py.


Constructor & Destructor Documentation

def migrate_ptk.Migrator.__init__ (   self,
  conversions,
  skip 
)

Definition at line 19 of file migrate_ptk.py.

00019 
00020     def __init__(self, conversions, skip):
00021         self.conversions = conversions
00022         self.skip = skip
00023         self.visited_folders = []
00024         self.warnings = []
00025         self.copied = []
00026         self.skipped = []


Member Function Documentation

def migrate_ptk.Migrator.migrateDiscussionContainer (   self,
  src_folder,
  dst_folder,
  place = () 
)

Definition at line 43 of file migrate_ptk.py.

00043 
00044     def migrateDiscussionContainer(self, src_folder, dst_folder, place=()):
00045         self.visited_folders.append( '/'.join(place) )
00046         dst_container = getattr(dst_folder, '_container', None)
00047         if dst_container is None:
00048             dst_container = dst_folder._container = PersistentMapping()
00049         for id, s_ob in src_folder._container.items():
00050             d_ob = dst_container.get(id)
00051             to_store = self.migrateObject(id, s_ob, d_ob, dst_folder,
00052                                           place + (id,))
00053             if to_store is not None:
00054                 dst_container[id] = aq_base(to_store)

Here is the call graph for this function:

Here is the caller graph for this function:

def migrate_ptk.Migrator.migrateObject (   self,
  id,
  s_ob,
  d_ob,
  dst_folder,
  place 
)

Definition at line 62 of file migrate_ptk.py.

00062 
00063     def migrateObject(self, id, s_ob, d_ob, dst_folder, place):
00064         # Doesn't store changes, only returns the
00065         # object to store.
00066         conversions = self.conversions
00067         klass = s_ob.__class__
00068         descend_ok = 1
00069         base_ob = aq_base(s_ob)
00070         to_store = None
00071         pathname = '/'.join(place)
00072         if self.skip.has_key(id):
00073             # Don't migrate objects by this name, but we can still
00074             # migrate subobjects.
00075             descend_ok = self.skip[id]
00076             if descend_ok and d_ob is None:
00077                 descend_ok = 0
00078             self.skipped.append(pathname +
00079                                (descend_ok and ' (descended)' or ' '))
00080         elif d_ob is not None:
00081             # The dest already has something with this ID.
00082             descend_ok = 1
00083             show_message = 1
00084             converter = conversions.get(klass, None)
00085             if converter is not None:
00086                 descend_ok = converter.allowDescendChildren()
00087                 show_message = converter.showDuplicationError()
00088             if show_message:
00089                 self.warnings.append('Already existed: %s' % pathname)
00090         elif conversions.has_key(klass):
00091             # Invoke the appropriate converter.
00092             converter = conversions[klass]
00093             to_store = converter.convert(s_ob)
00094             self.copied.append(pathname)
00095         elif hasattr(base_ob, '_getCopy'):
00096             # Make a direct copy.
00097             to_store = s_ob._getCopy(dst_folder)
00098             self.warnings.append('Copied %s directly.' % pathname)
00099             descend_ok = 0
00100         else:
00101             # No way to copy.
00102             descend_ok = 0
00103             self.warnings.append('Could not copy %s' % pathname)
00104         if descend_ok:
00105             if to_store is not None:
00106                 d_ob = to_store
00107             if d_ob is not None:
00108                 try: d_ob._p_jar = dst_folder._p_jar
00109                 except: pass
00110                 self.migratePossibleContainer(s_ob, d_ob, place)
00111         return to_store
00112 

Here is the call graph for this function:

Here is the caller graph for this function:

def migrate_ptk.Migrator.migrateObjectManager (   self,
  src_folder,
  dst_folder,
  place = () 
)

Definition at line 27 of file migrate_ptk.py.

00027 
00028     def migrateObjectManager(self, src_folder, dst_folder, place=()):
00029         self.visited_folders.append( '/'.join(place) )
00030         for id, s_ob in src_folder.objectItems():
00031             d_ob = getattr(dst_folder, id, None)
00032             to_store = self.migrateObject(id, s_ob, d_ob, dst_folder,
00033                                           place + (id,))
00034             if to_store is not None:
00035                 owner = getattr(to_store, '_owner', None)
00036                 if hasattr(dst_folder, '_setObject'):
00037                     dst_folder._setObject(id, to_store)
00038                 else:
00039                     setattr(dst_folder, id, to_store)
00040                 if owner is not None:
00041                     # Retain ownership.
00042                     to_store._owner = owner

Here is the call graph for this function:

Here is the caller graph for this function:

def migrate_ptk.Migrator.migratePossibleContainer (   self,
  s_ob,
  d_ob,
  place 
)

Definition at line 55 of file migrate_ptk.py.

00055 
00056     def migratePossibleContainer(self, s_ob, d_ob, place):
00057         base_ob = aq_base(s_ob)
00058         if hasattr(base_ob, 'objectItems'):
00059             self.migrateObjectManager(s_ob, d_ob, place)
00060         elif hasattr(base_ob, '_container'):
00061             self.migrateDiscussionContainer(s_ob, d_ob, place)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 20 of file migrate_ptk.py.

Definition at line 24 of file migrate_ptk.py.

Definition at line 21 of file migrate_ptk.py.

Definition at line 25 of file migrate_ptk.py.

Definition at line 22 of file migrate_ptk.py.

Definition at line 23 of file migrate_ptk.py.


The documentation for this class was generated from the following file: