Back to index

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

List of all members.

Public Member Functions

def prepare
def register
def save
def purge
def retrieve
def getHistory
def queryHistory
def isUpToDate

Static Public Attributes

string id = 'portal_archivist'
string alternative_id = 'portal_standard_archivist'
string meta_type = 'CMFEditions Portal Archivist Tool'
tuple interfaces
tuple exceptions
tuple classes
tuple security = ClassSecurityInfo()

Private Member Functions

def _cloneByPickle

Static Private Attributes

tuple __implements__

Detailed Description

Definition at line 144 of file ArchivistTool.py.


Member Function Documentation

def CMFEditions.ArchivistTool.ArchivistTool._cloneByPickle (   self,
  obj 
) [private]
Returns a deep copy of a ZODB object, loading ghosts as needed.

Definition at line 181 of file ArchivistTool.py.

00181 
00182     def _cloneByPickle(self, obj):
00183         """Returns a deep copy of a ZODB object, loading ghosts as needed.
00184         """
00185         modifier = getToolByName(self, 'portal_modifier')
00186         callbacks = modifier.getOnCloneModifiers(obj)
00187         if callbacks is not None:
00188             pers_id, pers_load, inside_orefs, outside_orefs = callbacks[0:4]
00189         else:
00190             inside_orefs, outside_orefs = (), ()
00191     
00192         stream = StringIO()
00193         p = Pickler(stream, 1)
00194         if callbacks is not None:
00195             p.persistent_id = pers_id
00196         p.dump(aq_base(obj))
00197         approxSize = stream.tell()
00198         stream.seek(0)
00199         u = Unpickler(stream)
00200         if callbacks is not None:
00201             u.persistent_load = pers_load
00202         return approxSize, u.load(), inside_orefs, outside_orefs
00203 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ArchivistTool.ArchivistTool.getHistory (   self,
  obj = None,
  history_id = None,
  preserve = (),
  countPurged = True 
)
See IPurgeSupport.

Definition at line 322 of file ArchivistTool.py.

00322 
00323                    countPurged=True):
00324         """See IPurgeSupport.
00325         """
00326         try:
00327             return LazyHistory(self, obj, history_id, preserve, countPurged)
00328         except StorageUnregisteredError:
00329             raise ArchivistUnregisteredError(
00330                 "Retrieving a version of an unregistered object is not "
00331                 "possible. Register the object '%s' first. " % obj)
        

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ArchivistTool.ArchivistTool.isUpToDate (   self,
  obj = None,
  history_id = None,
  selector = None,
  countPurged = True 
)
See IPurgeSupport.

Definition at line 344 of file ArchivistTool.py.

00344 
00345                    countPurged=True):
00346         """See IPurgeSupport.
00347         """
00348         storage = getToolByName(self, 'portal_historiesstorage')
00349         obj, history_id = dereference(obj, history_id, self)
00350         if not storage.isRegistered(history_id):
00351             raise ArchivistUnregisteredError(
00352                 "The object %s is not registered" % obj)
00353         
00354         modified = storage.getModificationDate(history_id, selector,
00355                                                countPurged)
00356         return modified == obj.modified()
00357 
00358 InitializeClass(ArchivistTool)
00359 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ArchivistTool.ArchivistTool.prepare (   self,
  obj,
  app_metadata = None,
  sys_metadata = {} 
)
See IArchivist.

Definition at line 209 of file ArchivistTool.py.

00209 
00210     def prepare(self, obj, app_metadata=None, sys_metadata={}):
00211         """See IArchivist.
00212         """
00213         storage = getToolByName(self, 'portal_historiesstorage')
00214         modifier = getToolByName(self, 'portal_modifier')
00215         
00216         obj, history_id = dereference(obj, zodb_hook=self)
00217         if storage.isRegistered(history_id):
00218             # already registered
00219             version_id = len(self.queryHistory(obj))
00220             is_registered = True
00221         else:
00222             # object isn't under version control yet
00223             # A working copy being under version control needs to have
00224             # a history_id, version_id (starts with 0) and a location_id
00225             # (the current implementation isn't able yet to handle multiple
00226             # locations. Nevertheless lets set the location id to a well
00227             # known default value)
00228             uidhandler = getToolByName(self, 'portal_historyidhandler')
00229             history_id = uidhandler.register(obj)
00230             version_id = obj.version_id = 0
00231             alsoProvides(obj, IVersioned)
00232             obj.location_id = 0
00233             is_registered = False
00234         
00235         # the hard work done here is:
00236         # 1. ask for all attributes that have to be passed to the 
00237         #    history storage by reference
00238         # 2. clone the object with some modifications
00239         # 3. modify the clone further
00240         referenced_data = modifier.getReferencedAttributes(obj)
00241         approxSize, clone, inside_orefs, outside_orefs = \
00242             self._cloneByPickle(obj)
00243         metadata, inside_crefs, outside_crefs = \
00244             modifier.beforeSaveModifier(obj, clone)
00245         
00246         # extend the ``sys_metadata`` by the metadata returned by the
00247         # ``beforeSaveModifier`` modifier
00248         sys_metadata.update(metadata)
00249         
00250         # set the version id of the clone to be saved to the repository
00251         # location_id and history_id are the same as on the working copy
00252         # and remain unchanged
00253         clone.version_id = version_id
00254         
00255         # return the prepared infos (clone, refs, etc.)
00256         clone_info = ObjectData(clone, inside_crefs, outside_crefs)
00257         obj_info = ObjectData(obj, inside_orefs, outside_orefs)
00258         return PreparedObject(history_id, obj_info, clone_info, 
00259                               referenced_data, app_metadata, 
00260                               sys_metadata, is_registered, approxSize)
        

Here is the call graph for this function:

def CMFEditions.ArchivistTool.ArchivistTool.purge (   self,
  obj = None,
  history_id = None,
  selector = None,
  metadata = {},
  countPurged = True 
)
See IPurgeSupport.

Definition at line 296 of file ArchivistTool.py.

00296 
00297               countPurged=True):
00298         """See IPurgeSupport.
00299         """
00300         storage = getToolByName(self, 'portal_historiesstorage')
00301         obj, history_id = dereference(obj, history_id, self)
00302         storage.purge(history_id, selector, metadata, countPurged)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ArchivistTool.ArchivistTool.queryHistory (   self,
  obj = None,
  history_id = None,
  preserve = (),
  default = [],
  countPurged = True 
)
See IPurgeSupport.

Definition at line 334 of file ArchivistTool.py.

00334 
00335                      countPurged=True):
00336         """See IPurgeSupport.
00337         """
00338         try:
00339             return LazyHistory(self, obj, history_id, preserve, countPurged)
00340         except StorageUnregisteredError:
00341             return default

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ArchivistTool.ArchivistTool.register (   self,
  prepared_obj 
)
See IArchivist.

Definition at line 262 of file ArchivistTool.py.

00262 
00263     def register(self, prepared_obj):
00264         """See IArchivist.
00265         """
00266         # only register at the storage layer if not yet registered
00267         if not prepared_obj.is_registered:
00268             storage = getToolByName(self, 'portal_historiesstorage')
00269             return storage.register(prepared_obj.history_id, 
00270                                     prepared_obj.clone, 
00271                                     prepared_obj.referenced_data,
00272                                     prepared_obj.metadata)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ArchivistTool.ArchivistTool.retrieve (   self,
  obj = None,
  history_id = None,
  selector = None,
  preserve = (),
  countPurged = True 
)
See IPurgeSupport.

Definition at line 305 of file ArchivistTool.py.

00305 
00306                  countPurged=True):
00307         """See IPurgeSupport.
00308         """
00309         # retrieve the object by accessing the right history entry 
00310         # (counting from the oldest version)
00311         # the histories storage called by LazyHistory knows what to do
00312         # with a None selector
00313         history = self.getHistory(obj, history_id, preserve, countPurged)
00314         try:
00315             return history[selector]
00316         except StorageRetrieveError:
00317             raise ArchivistRetrieveError(
00318                 "Retrieving of '%s' failed. Version '%s' does not exist. "
00319                 % (obj, selector))
    

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.ArchivistTool.ArchivistTool.save (   self,
  prepared_obj,
  autoregister = None 
)
See IArchivist.

Definition at line 274 of file ArchivistTool.py.

00274 
00275     def save(self, prepared_obj, autoregister=None):
00276         """See IArchivist.
00277         """
00278         if not prepared_obj.is_registered:
00279             if autoregister:
00280                 return self.register(prepared_obj)
00281             raise ArchivistSaveError(
00282                 "Saving an unregistered object is not possible. Register "
00283                 "the object '%s' first. "% prepared_obj.original.object)
00284         
00285         storage = getToolByName(self, 'portal_historiesstorage')
00286         return storage.save(prepared_obj.history_id, 
00287                             prepared_obj.clone, 
00288                             prepared_obj.referenced_data, 
00289                             prepared_obj.metadata)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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

Definition at line 148 of file ArchivistTool.py.

string CMFEditions.ArchivistTool.ArchivistTool.alternative_id = 'portal_standard_archivist' [static]

Definition at line 156 of file ArchivistTool.py.

Initial value:
KwAsAttributes(
        VersionData=VersionData,
        VersionAwareReference=VersionAwareReference,
        AttributeAdapter=AttributeAdapter,
    )

Definition at line 169 of file ArchivistTool.py.

Initial value:
KwAsAttributes(
        ArchivistError=ArchivistError,
    )

Definition at line 166 of file ArchivistTool.py.

string CMFEditions.ArchivistTool.ArchivistTool.id = 'portal_archivist' [static]

Definition at line 155 of file ArchivistTool.py.

Initial value:
KwAsAttributes(
        IVersionData=IVersionData,
        IVersionAwareReference=IVersionAwareReference,
        IAttributeAdapter=IAttributeAdapter,
    )

Definition at line 161 of file ArchivistTool.py.

string CMFEditions.ArchivistTool.ArchivistTool.meta_type = 'CMFEditions Portal Archivist Tool' [static]

Definition at line 158 of file ArchivistTool.py.

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

Definition at line 175 of file ArchivistTool.py.


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