Back to index

plone3  3.1.7
Classes | Functions | Variables
CMFEditions.ZVCStorageTool Namespace Reference

Classes

class  ZVCStorageTool
class  ShadowStorage
class  ShadowHistory
class  ZVCAwareWrapper
class  Removed
class  VersionData
class  LazyHistory
class  GetItemIterator

Functions

def deepCopy
def getSize

Variables

string __version__ = "$Revision: 1.18 $"
 Copyright (c) 2004, 2005, 2006 Alberto Berti, Gregoire Weber.
tuple logger = logging.getLogger('CMFEditions')

Function Documentation

Definition at line 66 of file ZVCStorageTool.py.

00066 
00067 def deepCopy(obj):
00068     stream = StringIO()
00069     p = Pickler(stream, 1)
00070     p.dump(obj)
00071     stream.seek(0)
00072     u = Unpickler(stream)
00073     return u.load()

Here is the caller graph for this function:

Calculate the size as cheap as possible

Definition at line 74 of file ZVCStorageTool.py.

00074 
00075 def getSize(obj):
00076     """Calculate the size as cheap as possible
00077     """
00078     # Try the cheap variants first.
00079     # Actually the checks ensure the code never fails but beeing sure
00080     # is better.
00081     try:
00082         # check if to return zero (length is zero)
00083         if len(obj) == 0:
00084             return 0
00085     except:
00086         pass
00087         
00088     try:
00089         # check if ``IStreamableReference``
00090         if IStreamableReference.isImplementedBy(obj):
00091             size = obj.getSize()
00092             if size is not None:
00093                 return size
00094     except:
00095         pass
00096         
00097     try:
00098         # string
00099         if isinstance(obj, types.StringTypes):
00100             return len(obj)
00101     except:
00102         pass
00103         
00104     try:
00105         # file like object
00106         methods = dir(obj)
00107         if "seek" in methods and "tell" in methods:
00108             currentPos = obj.tell()
00109             obj.seek(0, 2)
00110             size = obj.tell()
00111             obj.seek(currentPos)
00112             return size
00113     except:
00114         pass
00115     
00116     try:
00117         # fallback: pickling the object
00118         stream = StringIO()
00119         p = Pickler(stream, 1)
00120         p.dump(obj)
00121         size = stream.tell()
00122     except:
00123         size = None
00124     
00125     return size
00126 

Here is the caller graph for this function:


Variable Documentation

string CMFEditions.ZVCStorageTool.__version__ = "$Revision: 1.18 $"

Copyright (c) 2004, 2005, 2006 Alberto Berti, Gregoire Weber.

All Rights Reserved.

This file is part of CMFEditions.

CMFEditions is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

CMFEditions is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CMFEditions; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Definition at line 25 of file ZVCStorageTool.py.

tuple CMFEditions.ZVCStorageTool.logger = logging.getLogger('CMFEditions')

Definition at line 64 of file ZVCStorageTool.py.