Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes
CMFEditions.ZVCStorageTool.ZVCStorageTool Class Reference
Inheritance diagram for CMFEditions.ZVCStorageTool.ZVCStorageTool:
Inheritance graph
[legend]
Collaboration diagram for CMFEditions.ZVCStorageTool.ZVCStorageTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def isRegistered
def register
def save
def retrieve
def getHistory
def getModificationDate
def purge
def migrateStorage
def zmi_getStorageStatistics

Static Public Attributes

string id = 'portal_historiesstorage'
string alternative_id = 'portal_zvcstorage'
string meta_type = 'CMFEditions Portal ZVC based Histories Storage Tool'
tuple storageStatistics
tuple manage_options = ({'label' : 'Statistics (may take time)', 'action' : 'storageStatistics'}, )
 StorageError = StorageError
 StorageRetrieveError = StorageRetrieveError
 zvc_repo = None
tuple security = ClassSecurityInfo()

Private Member Functions

def _applyOrCheckin
def _getShadowStorage
def _getShadowHistory
def _getZVCRepo
def _getZVCAccessInfo
def _getVcInfo
def _retrieveZVCLogEntry
def _encodeMetadata
def _retrieveMetadataFromZVC
def _is10alpha3Layout

Static Private Attributes

tuple __implements__
 _shadowStorage = None

Detailed Description

Zope Version Control Based Version Storage

There exist two selector schemas:

- the one that counts removed versions also
- the one that counts non removed version only

Intended Usage:

For different use cases different numbering schemas are used:

- When iterating over the history the removed versions (usually) 
  aren't of interest. Thus the next valid version may be accessed
  by incrementing the selector and vice versa.
- When retrieving a version beeing able to access removed version
  or correctly spoken a substitute (pretending to be the removed 
  version) is important when reconstructing relations between 
  objects.

Definition at line 127 of file ZVCStorageTool.py.


Member Function Documentation

def CMFEditions.ZVCStorageTool.ZVCStorageTool._applyOrCheckin (   self,
  zvc_method,
  history_id,
  shadowInfo,
  object,
  referenced_data,
  metadata 
) [private]
Just centralizing similar code.

Definition at line 365 of file ZVCStorageTool.py.

00365 
00366                         object, referenced_data, metadata):
00367         """Just centralizing similar code.
00368         """
00369         # delegate the decision if and what to purge to the purge policy 
00370         # tool if one exists. If the call returns ``False`` do not save 
00371         # or register the current version.
00372         policy = getToolByName(self, 'portal_purgepolicy', None)
00373         if policy is not None:
00374             if not policy.beforeSaveHook(history_id, object, metadata):
00375                 # returning None signalizes that the version wasn't saved
00376                 return None
00377         
00378         # calculate the approximate size taking into account the object 
00379         # and the referenced_data (overwriting the archivists size as the
00380         # storage knows it better)
00381         approxSize = getSize(object) + getSize(referenced_data)
00382         metadata["sys_metadata"]["approxSize"] = approxSize
00383         
00384         # prepare the object for beeing saved with ZVC
00385         #
00386         # - Recall the ``__vc_info__`` from the most current version
00387         #   (selector=None).
00388         # - Wrap the object, the referenced data and metadata
00389         vc_info = self._getVcInfo(object, shadowInfo)
00390         zvc_obj = ZVCAwareWrapper(object, referenced_data, metadata, 
00391                                   vc_info)
00392         message = self._encodeMetadata(metadata)
00393         
00394         # call appropriate ZVC method
00395         zvc_method(zvc_obj, message)
00396         
00397         # save the ``__vc_info__`` attached by the zvc call from above
00398         # and cache the metadata in the shadow storage
00399         shadowInfo = {
00400             "vc_info": zvc_obj.__vc_info__,
00401             "metadata": metadata,
00402         }
00403         history = self._getShadowHistory(history_id, autoAdd=True)
00404         return history.save(shadowInfo)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool._encodeMetadata (   self,
  metadata 
) [private]

Definition at line 497 of file ZVCStorageTool.py.

00497 
00498     def _encodeMetadata(self, metadata):
00499         # metadata format is:
00500         #    - first line with trailing \x00: comment or empty comment
00501         #    - then: pickled metadata (incl. comment)
00502         try:
00503             comment = metadata['sys_metadata']['comment']
00504             comment = dumps(comment)
00505         except KeyError:
00506             comment = ''
00507         return '\x00\n'.join((comment, dumps(metadata, HIGHEST_PROTOCOL)))

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool._getShadowHistory (   self,
  history_id,
  autoAdd = False 
) [private]
Returns a History from the Shadow Storage

Definition at line 416 of file ZVCStorageTool.py.

00416 
00417     def _getShadowHistory(self, history_id, autoAdd=False):
00418         """Returns a History from the Shadow Storage
00419         """
00420         return self._getShadowStorage().getHistory(history_id, autoAdd)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool._getShadowStorage (   self,
  autoAdd = True 
) [private]
Returns the Shadow Storage

Returns None if there wasn't ever saved any version yet.

Definition at line 405 of file ZVCStorageTool.py.

00405 
00406     def _getShadowStorage(self, autoAdd=True):
00407         """Returns the Shadow Storage
00408         
00409         Returns None if there wasn't ever saved any version yet.
00410         """
00411         if self._shadowStorage is None:
00412             if not autoAdd:
00413                 return None
00414             self._shadowStorage = ShadowStorage()
00415         return self._shadowStorage

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool._getVcInfo (   self,
  obj,
  shadowInfo,
  set_checked_in = False 
) [private]
Recalls ZVC Related Informations and Attaches them to the Object

Definition at line 452 of file ZVCStorageTool.py.

00452 
00453     def _getVcInfo(self, obj, shadowInfo, set_checked_in=False):
00454         """Recalls ZVC Related Informations and Attaches them to the Object
00455         """
00456         vc_info = deepCopy(shadowInfo["vc_info"])
00457         if vc_info is None:
00458             return None
00459         
00460         # fake sticky information (no branches)
00461         vc_info.sticky = None
00462         
00463         # On revert operations the repository expects the object 
00464         # to be in CHECKED_IN state.
00465         if set_checked_in:
00466             vc_info.status = vc_info.CHECKED_IN
00467         else:
00468             vc_info.status = vc_info.CHECKED_OUT
00469         
00470         # fake the version to be able to save a retrieved version later
00471         zvc_repo = self._getZVCRepo()
00472         obj.__vc_info__ = vc_info
00473         vc_info.version_id = str(len(zvc_repo.getVersionIds(obj)))
00474         return vc_info

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool._getZVCAccessInfo (   self,
  history_id,
  selector,
  countPurged 
) [private]
Returns the ZVC history id and selector

Returns a tuple with the ZVC history id and selector.
Returns None as history id if such history doesn't exist.
Returns None as selector if the version does not exist.

Definition at line 430 of file ZVCStorageTool.py.

00430 
00431     def _getZVCAccessInfo(self, history_id, selector, countPurged):
00432         """Returns the ZVC history id and selector
00433         
00434         Returns a tuple with the ZVC history id and selector.
00435         Returns None as history id if such history doesn't exist.
00436         Returns None as selector if the version does not exist.
00437         """
00438         history = self._getShadowHistory(history_id)
00439         if history is None:
00440             # no history
00441             return None, None
00442         
00443         shadowInfo = history.retrieve(selector, countPurged)
00444         if shadowInfo is None:
00445             # no version
00446             return False, None
00447         
00448         # history and version exists
00449         zvc_hid = shadowInfo["vc_info"].history_id
00450         zvc_vid = str(history.getVersionId(selector, countPurged) + 1)
00451         return zvc_hid, zvc_vid

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the Zope Version Control Repository

Instantiates one with the first call.

Definition at line 421 of file ZVCStorageTool.py.

00421 
00422     def _getZVCRepo(self):
00423         """Returns the Zope Version Control Repository
00424         
00425         Instantiates one with the first call.
00426         """
00427         if self.zvc_repo is None:
00428             self.zvc_repo = ZopeRepository('repo', 'ZVC Storage')
00429         return self.zvc_repo

Here is the caller graph for this function:

Returns True if Storage is of 1.0alpha3 layout

Definition at line 520 of file ZVCStorageTool.py.

00520 
00521     def _is10alpha3Layout(self):
00522         """Returns True if Storage is of 1.0alpha3 layout
00523         """
00524         return getattr(self, "_history_id_mapping", None) is not None
    

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool._retrieveMetadataFromZVC (   self,
  zvc_histid,
  zvc_selector 
) [private]

Definition at line 508 of file ZVCStorageTool.py.

00508 
00509     def _retrieveMetadataFromZVC(self, zvc_histid, zvc_selector):
00510         logEntry = self._retrieveZVCLogEntry(zvc_histid, zvc_selector)
00511         metadata = loads(logEntry.message.split('\x00\n', 1)[1])
00512         return metadata
00513 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool._retrieveZVCLogEntry (   self,
  zvc_histid,
  zvc_selector 
) [private]
Retrieves the metadata from ZVCs log

Unfortunately this may get costy with long histories.
We should really store metadata in the shadow storage in the
future or loop over the log in reverse.

XXX also store (only store) the metadata in the shadow before 1.0beta1

Definition at line 475 of file ZVCStorageTool.py.

00475 
00476     def _retrieveZVCLogEntry(self, zvc_histid, zvc_selector):
00477         """Retrieves the metadata from ZVCs log
00478         
00479         Unfortunately this may get costy with long histories.
00480         We should really store metadata in the shadow storage in the
00481         future or loop over the log in reverse.
00482         
00483         XXX also store (only store) the metadata in the shadow before 1.0beta1
00484         """
00485         zvc_repo = self._getZVCRepo()
00486         log = zvc_repo.getVersionHistory(zvc_histid).getLogEntries()
00487         checkin = LogEntry.ACTION_CHECKIN
00488         entries = [e for e in log if e.version_id==zvc_selector and e.action==checkin]
00489         
00490         # just make a log entry if something wrong happened
00491         if len(entries) != 1:
00492             logger.log(logging.INFO, "CMFEditions ASSERT:"
00493                      "Uups, an object has been stored %s times with the same "
00494                      "history '%s'!!!" % (len(entries), zvc_selector))
00495         
00496         return entries[0]

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool.getHistory (   self,
  history_id,
  countPurged = True,
  substitute = True 
)
See IStorage.

Definition at line 293 of file ZVCStorageTool.py.

00293 
00294     def getHistory(self, history_id, countPurged=True, substitute=True):
00295         """See IStorage.
00296         """
00297         return LazyHistory(self, history_id, countPurged, substitute)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool.getModificationDate (   self,
  history_id,
  selector = None,
  countPurged = True,
  substitute = True 
)
See IStorage.

Definition at line 300 of file ZVCStorageTool.py.

00300 
00301                             countPurged=True, substitute=True):
00302         """See IStorage.
00303         """
00304         vdata = self.retrieve(history_id, selector, countPurged, substitute)
00305         return vdata.object.object.modified()
00306 

Here is the call graph for this function:

Here is the caller graph for this function:

See IStorage.

Definition at line 184 of file ZVCStorageTool.py.

00184 
00185     def isRegistered(self, history_id):
00186         """See IStorage.
00187         """
00188         # Do not wake up the ZODB (aka write to it) if there wasn't any
00189         # version saved yet.
00190         shadow_storage = self._getShadowStorage(autoAdd=False)
00191         if shadow_storage is None:
00192             return False
00193         return shadow_storage.isRegistered(history_id)
        

Here is the call graph for this function:

Here is the caller graph for this function:

Migrate the Storage to Newest Layout

Definition at line 525 of file ZVCStorageTool.py.

00525 
00526     def migrateStorage(self):
00527         """Migrate the Storage to Newest Layout
00528         """
00529         # check if already done
00530         if not self._is10alpha3Layout():
00531             logger.log(logging.INFO, "CMFEditions storage migration:"
00532                 "Storage already migrated.")
00533             return None
00534         
00535         startTime = time.time()
00536         logger.log(logging.INFO, "CMFEditions storage migration:"
00537             "started migrating the whole storage")
00538         from Products.ZopeVersionControl.Utility import VersionInfo
00539         
00540         # build reverse mapping: zvc history id --> CMFEditions history id
00541         logger.log(logging.INFO, "CMFEditions storage migration:"
00542             "preparing history mapping CMFEditions <--> ZVC")
00543         hidMapping = self._history_id_mapping
00544         hidReverseMapping = {}
00545         for hid, zvcHid in hidMapping.items():
00546             hidReverseMapping[zvcHid.history_id] = hid
00547             logger.log(logging.INFO, "CMFEditions storage migration:"
00548                 " %6i <--> %s" % (hid, zvcHid.history_id))
00549 
00550         # iterate over all histories
00551         logger.log(logging.INFO, "CMFEditions storage migration:"
00552             "iterating over all histories:")
00553         nbrOfMigratedHistories = 0
00554         nbrOfMigratedVersions = 0
00555         repo = self._getZVCRepo()
00556         for zvcHid in repo._histories.keys():
00557             zvcHistory = repo.getVersionHistory(zvcHid)
00558             zvcVersionIds = zvcHistory.getVersionIds()
00559             history_id = hidReverseMapping[zvcHid]
00560             history = self._getShadowHistory(history_id, autoAdd=True)
00561             logger.log(logging.INFO, "CMFEditions storage migration:"
00562                 " migrating %s versions of history %s (ZVC: %s)" 
00563                 % (len(zvcVersionIds), history_id, zvcHid))
00564             nbrOfMigratedHistories += 1
00565             
00566             # iterate over all versions
00567             for zvcVid in zvcVersionIds:
00568                 obj = zvcHistory.getVersionById(zvcVid)
00569                 vc_info = VersionInfo(zvcHid, zvcVid, VersionInfo.CHECKED_IN)
00570                 vc_info.timestamp = obj.date_created
00571                 metadata = self._retrieveMetadataFromZVC(zvcHid, zvcVid)
00572                 
00573                 # calculating approximate size
00574                 zvc_obj = repo.getVersionOfResource(zvcHid, zvcVid)
00575                 obj = zvc_obj.getWrappedObject()
00576                 referenced_data = zvc_obj.getReferencedData()
00577                 approxSize = getSize(obj) + getSize(referenced_data)
00578                 metadata["sys_metadata"]["approxSize"] = approxSize
00579                 
00580                 # we do not calculate version aware parent references
00581                 # (it's possible but rather complicated)
00582                 
00583                 # preparing administrative data
00584                 shadowInfo = {
00585                     "vc_info": vc_info,
00586                     "metadata": metadata,
00587                 }
00588                 
00589                 # save metadata in shadow history
00590                 logger.log(logging.INFO, "CMFEditions storage migration:"
00591                     " migrating version %s:" % (int(zvcVid)-1))
00592                 history.save(shadowInfo)
00593                 
00594                 app_metadata = metadata.get("app_metadata", {})
00595                 if app_metadata:
00596                     logger.log(logging.INFO, "CMFEditions storage migration:"
00597                         " application metadata:")
00598                     for item in app_metadata.items():
00599                         logger.log(logging.INFO,
00600                             "CMFEditions storage migration: %s = %s" % item)
00601                 sys_metadata = metadata.get("sys_metadata", {})
00602                 if sys_metadata:
00603                     logger.log(logging.INFO, "CMFEditions storage migration:"
00604                         " system metadata:")
00605                     for item in sys_metadata.items():
00606                         logger.log(logging.INFO,
00607                             "CMFEditions storage migration: %s = %s" % item)
00608                 nbrOfMigratedVersions += 1
00609         
00610         # delete the old metadata
00611         del self._history_id_mapping
00612         
00613         # log a summary
00614         totalTime = round(time.time() - startTime, 2)
00615         logger.log(logging.INFO, "CMFEditions storage migration:"
00616             "migrated %s histories and a total of %s versions in %.2f seconds" 
00617             % (nbrOfMigratedHistories, nbrOfMigratedVersions, totalTime))
00618         
00619         # XXX have to add purge policy
00620         
00621         return (nbrOfMigratedHistories, nbrOfMigratedVersions, totalTime)

Here is the call graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool.purge (   self,
  history_id,
  selector,
  metadata = {},
  countPurged = True 
)
See ``IPurgeSupport``

Definition at line 312 of file ZVCStorageTool.py.

00312 
00313     def purge(self, history_id, selector, metadata={}, countPurged=True):
00314         """See ``IPurgeSupport``
00315         """
00316         zvc_repo = self._getZVCRepo()
00317         zvc_histid, zvc_selector = \
00318             self._getZVCAccessInfo(history_id, selector, countPurged)
00319         if zvc_histid is None:
00320             raise StoragePurgeError(
00321                 "Purging version '%s' of object with history id '%s' "
00322                 "failed. A history with the given history id does not exist."
00323                 % (selector, history_id))
00324         
00325         if zvc_selector is None:
00326             raise StoragePurgeError(
00327                 "Purging version '%s' of object with history id '%s' "
00328                 "failed. The version does not exist." 
00329                 % (selector, history_id))
00330         
00331         # digging into ZVC internals:
00332         # Get a reference to the version stored in the ZVC history storage
00333         #
00334         # Implementation Note:
00335         #
00336         # ZVCs ``getVersionOfResource`` is quite more complex. But as we 
00337         # do not use labeling and branches it is not a problem to get the
00338         # version in the following simple way.
00339         zvc_history = zvc_repo.getVersionHistory(zvc_histid)
00340         version = zvc_history.getVersionById(zvc_selector)
00341         data = version._data
00342         
00343         if not isinstance(data.getWrappedObject(), Removed):
00344             # purge version in shadow storages history
00345             history = self._getShadowHistory(history_id)
00346             
00347             # update administrative data
00348             history.purge(selector, metadata, countPurged)
00349             
00350             # prepare replacement for the deleted object and metadata
00351             removedInfo = Removed("purged", metadata)
00352             
00353             # digging into ZVC internals: remove the stored object
00354             version._data = ZVCAwareWrapper(removedInfo, None, metadata)
00355             
00356             # digging into ZVC internals: replace the message
00357             logEntry = self._retrieveZVCLogEntry(zvc_histid, zvc_selector)
00358             logEntry.message = self._encodeMetadata(metadata)
00359 

Here is the call graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool.register (   self,
  history_id,
  object,
  referenced_data = {},
  metadata = None 
)
See IStorage.

Definition at line 195 of file ZVCStorageTool.py.

00195 
00196     def register(self, history_id, object, referenced_data={}, metadata=None):
00197         """See IStorage.
00198         """
00199         # check if already registered
00200         if self.isRegistered(history_id):
00201             return
00202         
00203         # No ZVC info available at register time
00204         shadowInfo = {"vc_info": None}
00205         zvc_method = self._getZVCRepo().applyVersionControl
00206         try:
00207             return self._applyOrCheckin(zvc_method, history_id, shadowInfo,
00208                                         object, referenced_data, metadata)
00209         except VersionControlError:
00210             raise StorageRegisterError(
00211                 "Registering the object with history id '%s' failed. "
00212                 "The underlying storage implementation reported an error."
00213                 % history_id)
        

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool.retrieve (   self,
  history_id,
  selector = None,
  countPurged = True,
  substitute = True 
)
See ``IStorage`` and Comments in ``IPurgePolicy``

Definition at line 242 of file ZVCStorageTool.py.

00242 
00243                  countPurged=True, substitute=True):
00244         """See ``IStorage`` and Comments in ``IPurgePolicy``
00245         """
00246         zvc_repo = self._getZVCRepo()
00247         zvc_histid, zvc_selector = \
00248             self._getZVCAccessInfo(history_id, selector, countPurged)
00249         
00250         if zvc_histid is None:
00251             raise StorageRetrieveError(
00252                 "Retrieving version '%s' of object with history id '%s' "
00253                 "failed. A history with the given history id does not exist."
00254                 % (selector, history_id))
00255         
00256         if zvc_selector is None:
00257             raise StorageRetrieveError(
00258                 "Retrieving version '%s' of object with history id '%s' "
00259                 "failed. The version does not exist."
00260                 % (selector, history_id))
00261         
00262         # retrieve the object
00263         try:
00264             zvc_obj = zvc_repo.getVersionOfResource(zvc_histid, zvc_selector)
00265         except VersionControlError:
00266             # this should never happen
00267             raise StorageRetrieveError(
00268                 "Retrieving version '%s' of object with history id '%s' "
00269                 "failed. The underlying storage implementation reported "
00270                 "an error." % (selector, history_id))
00271         
00272         # retrieve metadata
00273         # TODO: read this from the shadow storage directly
00274         metadata = self._retrieveMetadataFromZVC(zvc_histid, zvc_selector)
00275         
00276         # wrap object and referenced data
00277         object = zvc_obj.getWrappedObject()
00278         referenced_data = zvc_obj.getReferencedData()
00279         data = VersionData(object, referenced_data, metadata)
00280         
00281         # check if retrieved a replacement for a removed object and 
00282         # if so check if a substitute is available
00283         if substitute and isinstance(data.object, Removed):
00284             # delegate retrieving to purge policy if one is available
00285             # if none is available just return the replacement for the
00286             # removed object
00287             policy = getToolByName(self, 'portal_purgepolicy', None)
00288             if policy is not None:
00289                 data = policy.retrieveSubstitute(history_id, selector, 
00290                                                  default=data)
00291         return data

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ZVCStorageTool.ZVCStorageTool.save (   self,
  history_id,
  object,
  referenced_data = {},
  metadata = None 
)
See IStorage.

Definition at line 215 of file ZVCStorageTool.py.

00215 
00216     def save(self, history_id, object, referenced_data={}, metadata=None):
00217         """See IStorage.
00218         """
00219         # check if already registered
00220         if not self.isRegistered(history_id):
00221             raise StorageUnregisteredError(
00222                 "Saving an unregistered object is not possible. "
00223                 "Register the object with history id '%s' first. "
00224                 % history_id)
00225         
00226         # retrieve the ZVC info from the youngest version
00227         history = self._getShadowHistory(history_id, autoAdd=True)
00228         shadowInfo = history.retrieve(selector=None, countPurged=True)
00229         
00230         zvc_method = self._getZVCRepo().checkinResource
00231         try:
00232             return self._applyOrCheckin(zvc_method, history_id, shadowInfo,
00233                                         object, referenced_data, metadata)
00234         except VersionControlError:
00235             # this shouldn't really happen
00236             raise StorageSaveError(
00237                 "Saving the object with history id '%s' failed. "
00238                 "The underlying storage implementation reported an error."
00239                 % history_id)

Here is the call graph for this function:

Definition at line 627 of file ZVCStorageTool.py.

00627 
00628     def zmi_getStorageStatistics(self):
00629         """
00630         """
00631         startTime = time.time()
00632         # get all history ids (incl. such that were deleted in the portal)
00633         storage = self._getShadowStorage(autoAdd=False)
00634         if storage is not None:
00635             historyIds = storage._storage
00636         else:
00637             historyIds = {}
00638         hidhandler = getToolByName(self, "portal_historyidhandler")
00639         portal_paths_len = len(getToolByName(self, "portal_url")())
00640         
00641         # collect interesting informations
00642         histories = []
00643         for hid in historyIds.keys():
00644             history = self.getHistory(hid)
00645             length = len(history)
00646             shadowStorage = self._getShadowHistory(hid)
00647             size = 0
00648             sizeState = "n/a"
00649             if shadowStorage is not None:
00650                 size, sizeState = shadowStorage.getSize()
00651             
00652             workingCopy = hidhandler.queryObject(hid)
00653             if workingCopy is not None:
00654                 url = workingCopy.absolute_url()
00655                 path = url[portal_paths_len:]
00656                 portal_type = workingCopy.getPortalTypeName()
00657             else:
00658                 path = None
00659                 url = None
00660                 retrieved = self.retrieve(hid).object.object
00661                 portal_type = retrieved.getPortalTypeName()
00662             histData = {
00663                 "history_id": hid, 
00664                 "length": length, 
00665                 "url": url, 
00666                 "path": path, 
00667                 "portal_type": portal_type, 
00668                 "size": size,
00669                 "sizeState": sizeState,
00670             }
00671             histories.append(histData)
00672         
00673         # collect history ids with still existing working copies
00674         existing = []
00675         existingHistories = 0
00676         existingVersions = 0
00677         existingSize = 0
00678         deleted = []
00679         deletedHistories = 0
00680         deletedVersions = 0
00681         deletedSize = 0
00682         for histData in histories:
00683             if histData["path"] is None:
00684                 deleted.append(histData)
00685                 deletedHistories += 1
00686                 deletedVersions += histData["length"]
00687                 deletedSize += 0 # TODO
00688             else:
00689                 existing.append(histData)
00690                 existingHistories += 1
00691                 existingVersions += histData["length"]
00692                 existingSize += 0 # TODO
00693         
00694         processingTime = "%.2f" % round(time.time() - startTime, 2)
00695         histories = existingHistories+deletedHistories
00696         versions = existingVersions+deletedVersions
00697         
00698         if histories:
00699             totalAverage = "%.1f" % round(float(versions)/histories, 1)
00700         else:
00701             totalAverage = "n/a"
00702         
00703         if existingHistories:
00704             existingAverage = "%.1f" % \
00705                 round(float(existingVersions)/existingHistories, 1)
00706         else:
00707             existingAverage = "n/a"
00708         
00709         if deletedHistories:
00710             deletedAverage = "%.1f" % \
00711                 round(float(deletedVersions)/deletedHistories, 1)
00712         else:
00713             deletedAverage = "n/a"
00714         
00715         return {
00716             "existing": existing, 
00717             "deleted": deleted, 
00718             "summaries": {
00719                 "time": processingTime,
00720                 "totalHistories": histories,
00721                 "totalVersions": versions,
00722                 "totalAverage": totalAverage,
00723                 "existingHistories": existingHistories,
00724                 "existingVersions": existingVersions,
00725                 "existingAverage": existingAverage,
00726                 "deletedHistories": deletedHistories,
00727                 "deletedVersions": deletedVersions,
00728                 "deletedAverage": deletedAverage,
00729             }
00730         }
00731 
00732 InitializeClass(ZVCStorageTool)
00733 

Here is the call graph for this function:


Member Data Documentation

Initial value:
(
        IPurgeSupport,
        IStorage,
        SimpleItem.__implements__,
    )

Definition at line 148 of file ZVCStorageTool.py.

Definition at line 172 of file ZVCStorageTool.py.

string CMFEditions.ZVCStorageTool.ZVCStorageTool.alternative_id = 'portal_zvcstorage' [static]

Definition at line 156 of file ZVCStorageTool.py.

string CMFEditions.ZVCStorageTool.ZVCStorageTool.id = 'portal_historiesstorage' [static]

Definition at line 155 of file ZVCStorageTool.py.

tuple CMFEditions.ZVCStorageTool.ZVCStorageTool.manage_options = ({'label' : 'Statistics (may take time)', 'action' : 'storageStatistics'}, ) [static]

Definition at line 163 of file ZVCStorageTool.py.

string CMFEditions.ZVCStorageTool.ZVCStorageTool.meta_type = 'CMFEditions Portal ZVC based Histories Storage Tool' [static]

Definition at line 158 of file ZVCStorageTool.py.

tuple CMFEditions.ZVCStorageTool.ZVCStorageTool.security = ClassSecurityInfo() [static]

Definition at line 177 of file ZVCStorageTool.py.

Definition at line 167 of file ZVCStorageTool.py.

Definition at line 168 of file ZVCStorageTool.py.

Initial value:
PageTemplateFile('www/storageStatistics.pt',
                                         globals(),
                                         __name__='modifierEditForm')

Definition at line 160 of file ZVCStorageTool.py.

Definition at line 175 of file ZVCStorageTool.py.


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