Back to index

plone3  3.1.7
Classes | Functions | Variables
ZopeVersionControl.Version Namespace Reference

Classes

class  Version

Functions

def cloneByPickle

Variables

string __version__ = '$Revision: 1.11 $'
 Copyright (c) 2001 Zope Corporation and Contributors.

Function Documentation

def ZopeVersionControl.Version.cloneByPickle (   obj,
  ignore_list = () 
)
Makes a copy of a ZODB object, loading ghosts as needed.

Ignores specified objects along the way, replacing them with None
in the copy.

Definition at line 31 of file Version.py.

00031 
00032 def cloneByPickle(obj, ignore_list=()):
00033     """Makes a copy of a ZODB object, loading ghosts as needed.
00034 
00035     Ignores specified objects along the way, replacing them with None
00036     in the copy.
00037     """
00038     ignore_dict = {}
00039     for o in ignore_list:
00040         ignore_dict[id(o)] = o
00041 
00042     def persistent_id(ob, ignore_dict=ignore_dict):
00043         if ignore_dict.has_key(id(ob)):
00044             return 'ignored'
00045         if getattr(ob, '_p_changed', 0) is None:
00046             ob._p_changed = 0
00047         return None
00048 
00049     def persistent_load(ref):
00050         assert ref == 'ignored'
00051         # Return a placeholder object that will be replaced by
00052         # removeNonVersionedData().
00053         placeholder = SimpleItem()
00054         placeholder.id = "ignored_subobject"
00055         return placeholder
00056 
00057     stream = StringIO()
00058     p = Pickler(stream, 1)
00059     p.persistent_id = persistent_id
00060     p.dump(obj)
00061     stream.seek(0)
00062     u = Unpickler(stream)
00063     u.persistent_load = persistent_load
00064     return u.load()
00065 

Here is the caller graph for this function:


Variable Documentation

string ZopeVersionControl.Version.__version__ = '$Revision: 1.11 $'

Copyright (c) 2001 Zope Corporation and Contributors.

All Rights Reserved.

This software is subject to the provisions of the Zope Public License, Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE

Definition at line 14 of file Version.py.