Back to index

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

List of all members.

Public Member Functions

def isVersionable
def getVersionableContentTypes
def setVersionableContentTypes
def addPolicyForContentType
def removePolicyFromContentType
def supportsPolicy
def hasPolicy
def manage_setTypePolicies
def listPolicies
def addPolicy
def removePolicy
def manage_changePolicyDefs
def getPolicyMap
def setAutoApplyMode
def applyVersionControl
def save
def purge
def revert
def retrieve
def restore
def getHistory
def isUpToDate
def createTestHierarchy

Static Public Attributes

string id = 'portal_repository'
string alternative_id = 'portal_copymergerepository'
string meta_type = 'CMFEditions Standard Copy Modify Merge Repository'
 autoapply = True
tuple security = ClassSecurityInfo()
list manage_options = SimpleItem.manage_options[1:]
 setVersionableContentType = setVersionableContentTypes

Private Member Functions

def _migrateVersionPolicies
def _callPolicyHook
def _assertAuthorized
def _prepareSysMetadata
def _recursiveSave
def _retrieve
def _recursiveRetrieve
def _doInplaceFixups
def _fixupCatalogData
def _fixupATReferences
def _fixIds

Static Private Attributes

tuple __implements__
 _versionable_content_types = VERSIONABLE_CONTENT_TYPES
 _version_policy_mapping = VERSION_POLICY_MAPPING
 _policy_defs = VERSION_POLICY_DEFS

Detailed Description

See ICopyModifyMergeRepository

Definition at line 78 of file CopyModifyMergeRepositoryTool.py.


Member Function Documentation

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool._assertAuthorized (   self,
  obj,
  permission,
  name = None 
) [private]

Definition at line 402 of file CopyModifyMergeRepositoryTool.py.

00402 
00403     def _assertAuthorized(self, obj, permission, name=None):
00404         # We need to provide access to the repository upon the object
00405         # permissions istead of repositories method permissions.
00406         # So the repository method access is set to public and the
00407         # access is check on the object when needed.
00408         if not _checkPermission(permission, obj):
00409             raise Unauthorized(name)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool._callPolicyHook (   self,
  action,
  policy_id,
  args,
  kw 
) [private]

Definition at line 244 of file CopyModifyMergeRepositoryTool.py.

00244 
00245     def _callPolicyHook(self, action, policy_id, *args, **kw):
00246         # in 1.0alpha3 and earlier ``version_on_revert`` was 
00247         # ``version_on_rollback``. Convert to new name.
00248         if policy_id == "version_on_revert":
00249             if "version_on_rollback" in self._policy_defs:
00250                 value = self._policy_defs["version_on_rollback"]
00251                 self._policy_defs["version_on_revert"] = value
00252                 del self._policy_defs["version_on_rollback"]
00253         
00254         hook = getattr(self._policy_defs[policy_id], HOOKS[action], None)
00255         if hook is not None and callable(hook):
00256             portal = getToolByName(self, 'portal_url').getPortalObject()
00257             hook(portal, *args, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

Perform fixups to deal with implementation details
(especially zodb and cmf details) which need to be done in
each retrieved object.

Definition at line 600 of file CopyModifyMergeRepositoryTool.py.

00600 
00601     def _doInplaceFixups(self, queue, inplace):
00602         """ Perform fixups to deal with implementation details
00603         (especially zodb and cmf details) which need to be done in
00604         each retrieved object."""
00605         for obj in queue:
00606             if inplace:
00607                 if not WRONG_AT:
00608                     self._fixupATReferences(obj)
00609                 self._fixIds(obj)
00610                 self._fixupCatalogData(obj)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 663 of file CopyModifyMergeRepositoryTool.py.

00663 
00664     def _fixIds(self, obj):
00665         items = getattr(obj ,'objectItems', None)
00666         if callable(items):
00667             temp_ids = []
00668             # find sub-objects whose id doesn't match the name in the container
00669             # remove them from the folder temporarily. This could probably be made
00670             # more efficient.  We assume that any id inconsistencies were created by
00671             # us, and fix accordingly.
00672             for orig_id, child in items():
00673                 real_id = child.getId()
00674                 if orig_id != real_id:
00675                     obj._delOb(orig_id)
00676                     object_list = getattr(obj, '_objects', None)
00677                     if object_list is not None:
00678                         obj._objects = tuple([o for o in object_list if o['id'] != orig_id])
00679                     temp_ids.append((real_id, child))
00680             # Make a second pass to move the objects into place if possible
00681             all_ids = list(obj.objectIds())
00682             for new_id, child in temp_ids:
00683                 if new_id not in all_ids:
00684                     # XXX: This calls child.manage_afterAdd, and it's not clear that we
00685                     # should do so, perhaps manually manipulating the _objects is the
00686                     # better way to go.
00687                     obj._setObject(new_id, child)
00688                     all_ids.append(new_id)
00689                 else:
00690                     # If we really can't add the object make the temp_id permanent
00691                     temp_id = new_id + STUB_OBJECT_PREFIX
00692                     child.id = temp_id
00693                     obj._setObject(temp_id, child)
00694                     all_ids.append(temp_id)

Here is the caller graph for this function:

Reindex AT reference data, and delete reference
implementations when the target
doesn't exist anymore.

Deletion of references is done at the end of the
recursiveRetrieve operation to avoid deleting refs to targets
that will be retrieved later in the recursiveRetrive. It
doesn't call refcatalog.deleteReference as that method uses
brains to retrieve reference implementations. If the
target doesn't exist, brains for references pointing to it
do not exist either.

This manually calls reference.delHook to let it finalize
correctly but traps ReferenceException eventually emitted in
the process and forces the deletion, because leaving the
reference impl. there will leave refcatalog in an
incosistent state.

Definition at line 623 of file CopyModifyMergeRepositoryTool.py.

00623 
00624     def _fixupATReferences(self, obj):
00625         """Reindex AT reference data, and delete reference
00626         implementations when the target
00627         doesn't exist anymore.
00628 
00629         Deletion of references is done at the end of the
00630         recursiveRetrieve operation to avoid deleting refs to targets
00631         that will be retrieved later in the recursiveRetrive. It
00632         doesn't call refcatalog.deleteReference as that method uses
00633         brains to retrieve reference implementations. If the
00634         target doesn't exist, brains for references pointing to it
00635         do not exist either.
00636 
00637         This manually calls reference.delHook to let it finalize
00638         correctly but traps ReferenceException eventually emitted in
00639         the process and forces the deletion, because leaving the
00640         reference impl. there will leave refcatalog in an
00641         incosistent state.
00642         """
00643 
00644         if IReferenceable.isImplementedBy(obj) and hasattr(obj, REFERENCES_CONTAINER_NAME):
00645             # Delete refs if their target doesn't exists anymore
00646             ref_folder = getattr(obj, REFERENCES_CONTAINER_NAME)
00647             uid_catalog = getToolByName(self, 'uid_catalog')
00648             ref_catalog = getToolByName(self, 'reference_catalog')
00649             ref_objs = ref_folder.objectValues()
00650             for ref in ref_objs:
00651                 if not uid_catalog(UID=ref.targetUID):
00652                     try:
00653                         # at's _deleteReference passes the catalog
00654                         # itself, the source and target obj... i'm
00655                         # going to emulate it as much as i can
00656                         ref.delHook(ref_catalog, obj, None)
00657                     except ReferenceException:
00658                         pass
00659                     ref_folder.manage_delObjects(ref.getId())
00660             # then reindex references
00661             container = aq_parent(aq_inner(obj))
00662             obj._updateCatalog(container)

Here is the call graph for this function:

Here is the caller graph for this function:

Reindex the object, otherwise the catalog will certainly
be out of sync.

Definition at line 611 of file CopyModifyMergeRepositoryTool.py.

00611 
00612     def _fixupCatalogData(self, obj):
00613         """ Reindex the object, otherwise the catalog will certainly
00614         be out of sync."""
00615         portal_catalog = getToolByName(self, 'portal_catalog')
00616         portal_catalog.reindexObject(obj)
00617         # XXX: In theory we should probably be emitting IObjectModified and
00618         # IObjectMoved events here as those are the possible consequences of a
00619         # revert. Perhaps in out current meager z2 existence we should do
00620         # obj.manage_afterRename()?  Also, should we be doing obj.reindexObject()
00621         # instead to make sure we maximally cover specialized classes which want
00622         # to handle their cataloging in special ways.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 107 of file CopyModifyMergeRepositoryTool.py.

00107 
00108     def _migrateVersionPolicies(self):
00109         if not isinstance(self._policy_defs, OOBTree):
00110             btree_defs = OOBTree()
00111             for obj_id, title in self._policy_defs.items():
00112                 btree_defs[obj_id]=VersionPolicy(obj_id, title)
00113             self._policy_defs = btree_defs

Definition at line 410 of file CopyModifyMergeRepositoryTool.py.

00410 
00411     def _prepareSysMetadata(self, comment):
00412         return {
00413             # comment is system metadata
00414             'comment': comment,
00415             # setting a timestamp here set the same timestamp at all
00416             # recursively saved objects
00417             'timestamp': time.time(),
00418             # None means the current object is the originator of the
00419             # save or purge operation
00420             'originator': None,
00421         }

Here is the caller graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool._recursiveRetrieve (   self,
  obj = None,
  history_id = None,
  selector = None,
  preserve = (),
  inplace = False,
  source = None,
  fixup_queue = None,
  ignore_existing = False,
  countPurged = True 
) [private]
This is the real workhorse pulling objects out recursively.

Definition at line 482 of file CopyModifyMergeRepositoryTool.py.

00482 
00483                            ignore_existing=False, countPurged=True):
00484         """This is the real workhorse pulling objects out recursively.
00485         """
00486         portal_archivist = getToolByName(self, 'portal_archivist')
00487         portal_reffactories = getToolByName(self, 'portal_referencefactories')
00488         if ignore_existing:
00489             obj = None
00490         else:
00491             obj, history_id = dereference(obj, history_id, self)
00492 
00493         hasBeenDeleted = obj is None
00494 
00495         # CMF's invokeFactory needs the added object be traversable from
00496         # itself to the root and from the root to the itself. This is the
00497         # reason why it is necessary to replace the working copies current
00498         # state with the one of the versions state retrieved. If the
00499         # operation is not an inplace operation (retrieve instead of
00500         # revert) this has to be reversed after having recursed into the
00501         # tree.
00502         if hasBeenDeleted:
00503             # if the object to retreive doesn't have a counterpart in the tree
00504             # build a new one before retrieving an old state
00505             vdata = portal_archivist.retrieve(obj, history_id, selector, 
00506                                               preserve, countPurged)
00507             repo_clone = vdata.data.object
00508             obj = portal_reffactories.invokeFactory(repo_clone, source)
00509             hasBeenMoved = False
00510         else:
00511             if source is None:
00512                 ##### the source has to be stored with the object at save time
00513                 # I(gregweb)'m pretty sure the whole source stuff here gets
00514                 # obsolete as soon as a va_ref to the source is stored also
00515                 # XXX for now let's stick with this:
00516                 source = aq_parent(aq_inner(obj))
00517 
00518             # in the special case the object has been moved the retrieved
00519             # object has to get a new history (it's like copying back back
00520             # the object and then retrieve an old state)
00521             hasBeenMoved = portal_reffactories.hasBeenMoved(obj, source)
00522 
00523         if hasBeenMoved:
00524             if getattr(aq_base(source), obj.getId(), None) is None:
00525                 vdata = portal_archivist.retrieve(obj, history_id, selector, 
00526                                                   preserve, countPurged)
00527                 repo_clone = vdata.data.object
00528                 obj = portal_reffactories.invokeFactory(repo_clone, source)
00529             else:
00530                 # What is the desired behavior
00531                 pass
00532         
00533         vdata = portal_archivist.retrieve(obj, history_id, selector, 
00534                                           preserve, countPurged)
00535         
00536         # Replace the objects attributes retaining identity.
00537         _missing = object()
00538         attrs_to_leave = vdata.attr_handling_references
00539         for key, val in vdata.data.object.__dict__.items():
00540             if key in attrs_to_leave:
00541                 continue
00542             obj_val = getattr(aq_base(obj), key, _missing)
00543             setattr(obj, key, val)
00544 
00545         # Delete reference attributes.
00546         for ref in vdata.refs_to_be_deleted:
00547             ref.remove(permanent=inplace)
00548 
00549         # retrieve all inside refs
00550         for attr_ref in vdata.data.inside_refs:
00551             # get the referenced working copy
00552             # XXX if the working copy we're searching for was moved to
00553             # somewhere else *outside* we generate an another object with
00554             # the same history_id. Unfortunately we're not able to handle
00555             # this correctly before multi location stuff is implemented.
00556             # XXX Perhaps there is a need for a workaround!
00557             va_ref = attr_ref.getAttribute()
00558             if va_ref is None:
00559                 # a missing reference, the policy has changed,
00560                 # don't try to replace it
00561                 continue
00562             history_id = va_ref.history_id
00563 
00564             # retrieve the referenced version (always count purged versions
00565             # also!)
00566             ref_vdata= self._recursiveRetrieve(history_id=history_id,
00567                                                selector=va_ref.version_id,
00568                                                preserve=(),
00569                                                inplace=inplace,
00570                                                source=obj,
00571                                                fixup_queue=fixup_queue,
00572                                                ignore_existing=ignore_existing,
00573                                                countPurged=True)
00574 
00575             # reattach the python reference
00576             attr_ref.setAttribute(ref_vdata.data.object)
00577 
00578         # reattach all outside refs to the current working copy
00579         # XXX this is an implicit policy we can live with for now
00580         for attr_ref in vdata.data.outside_refs:
00581             va_ref = attr_ref.getAttribute()
00582             # If the attribute has been removed by a modifier, then we get
00583             # None, move on to the next ref.
00584             if va_ref is None:
00585                 continue
00586             try:
00587                 ref = dereference(history_id=va_ref.history_id, zodb_hook=self)[0]
00588             except TypeError:
00589                 ref = getattr(aq_base(obj), attr_ref.getAttributeName(), None)
00590             # If the object is not under version control just
00591             # attach the current working copy if it exists
00592             if ref is not None:
00593                 attr_ref.setAttribute(ref)
00594 
00595         # feed the fixup queue defined in revert() and retrieve() to
00596         # perform post-retrieve fixups on the object
00597         if fixup_queue is not None:
00598            fixup_queue.append(obj)
00599         return vdata

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool._recursiveSave (   self,
  obj,
  app_metadata,
  sys_metadata,
  autoapply 
) [private]

Definition at line 422 of file CopyModifyMergeRepositoryTool.py.

00422 
00423     def _recursiveSave(self, obj, app_metadata, sys_metadata, autoapply):
00424         # prepare the save of the originating working copy
00425         portal_archivist = getToolByName(self, 'portal_archivist')
00426         prep = portal_archivist.prepare(obj, app_metadata, sys_metadata)
00427 
00428         # set the originator of the save operation for the referenced
00429         # objects
00430         if sys_metadata['originator'] is None:
00431             clone = prep.clone.object
00432             sys_metadata['originator'] = "%s.%s.%s" % (prep.history_id,
00433                                                        clone.version_id,
00434                                                        clone.location_id, )
00435 
00436         # What comes now is the current hardcoded policy:
00437         #
00438         # - recursively save inside references, then set a version aware
00439         #   reference
00440         # - on outside references only set a version aware reference
00441         #   (if under version control)
00442         inside_refs = map(lambda original_refs, clone_refs:
00443                           (original_refs, clone_refs.getAttribute()),
00444                           prep.original.inside_refs, prep.clone.inside_refs)
00445         for orig_ref, clone_ref in inside_refs:
00446             self._recursiveSave(orig_ref, app_metadata, sys_metadata,
00447                                 autoapply)
00448             clone_ref.setReference(orig_ref, remove_info=True)
00449 
00450         outside_refs = map(lambda oref, cref: (oref, cref.getAttribute()),
00451                            prep.original.outside_refs, prep.clone.outside_refs)
00452         for orig_ref, clone_ref in outside_refs:
00453             clone_ref.setReference(orig_ref, remove_info=True)
00454 
00455         portal_archivist.save(prep, autoregister=autoapply)
00456 
00457         # just to ensure that the working copy has the correct
00458         # ``verision_id``
00459         prep.copyVersionIdFromClone()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool._retrieve (   self,
  obj,
  selector,
  preserve,
  countPurged 
) [private]
Retrieve a former state.

Puts the returned version into same context as the working copy is
(to make attribute access acquirable).

Definition at line 460 of file CopyModifyMergeRepositoryTool.py.

00460 
00461     def _retrieve(self, obj, selector, preserve, countPurged):
00462         """Retrieve a former state.
00463 
00464         Puts the returned version into same context as the working copy is
00465         (to make attribute access acquirable).
00466         """
00467         # We make a savepoint so that we can undo anything that happened
00468         # during the transaction.  There may be resource managers which do not
00469         # support savepoints, those will raise errors here, which means that
00470         # retrieve and getHistory should not be used as a part of more
00471         # complex transactions.
00472         saved = transaction.savepoint()
00473         vd = self._recursiveRetrieve(obj=obj, selector=selector,
00474                                      preserve=preserve, inplace=False,
00475                                      countPurged=countPurged)
00476         saved.rollback()
00477         wrapped = wrap(vd.data.object, aq_parent(aq_inner(obj)))
00478         return VersionData(wrapped, vd.preserved_data,
00479                            vd.sys_metadata, vd.app_metadata)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool.addPolicy (   self,
  policy_id,
  policy_title,
  policy_class = VersionPolicy,
  kw 
)

Definition at line 198 of file CopyModifyMergeRepositoryTool.py.

00198 
00199                                                                         **kw):
00200         self._policy_defs[policy_id]=policy_class(policy_id,policy_title)
00201         self._callPolicyHook('add', policy_id, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 139 of file CopyModifyMergeRepositoryTool.py.

00139 
00140     def addPolicyForContentType(self, content_type, policy_id, **kw):
00141         assert self._policy_defs.has_key(policy_id), "Unknown policy %s"%policy_id
00142         policies = self._version_policy_mapping.copy()
00143         cur_policy = policies.setdefault(content_type, [])
00144         if policy_id not in cur_policy:
00145             cur_policy.append(policy_id)
00146             self._callPolicyHook('enable', policy_id, content_type, **kw)
00147         self._version_policy_mapping = policies

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool.applyVersionControl (   self,
  obj,
  comment = '',
  metadata = {} 
)
See ICopyModifyMergeRepository.

Definition at line 269 of file CopyModifyMergeRepositoryTool.py.

00269 
00270     def applyVersionControl(self, obj, comment='', metadata={}):
00271         """See ICopyModifyMergeRepository.
00272         """
00273         self._assertAuthorized(obj, ApplyVersionControl, 'applyVersionControl')
00274         sp = transaction.savepoint(optimistic=True)
00275         try:
00276             self._recursiveSave(obj, metadata,
00277                                 self._prepareSysMetadata(comment),
00278                                 autoapply=True)
00279         except ModifierException:
00280             # modifiers can abort save operations under certain conditions
00281             sp.rollback()
00282             raise

Here is the call graph for this function:

Create a Content Test Hierarchy

Definition at line 699 of file CopyModifyMergeRepositoryTool.py.

00699 
00700     def createTestHierarchy(self, context):
00701         """Create a Content Test Hierarchy
00702         """
00703         # XXX to be allowed in test mode only
00704         from StorageMigrationSupport import createTestHierarchy
00705         createTestHierarchy(context)
00706 

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool.getHistory (   self,
  obj,
  oldestFirst = False,
  preserve = (),
  countPurged = True 
)
See IPurgeSupport.

Definition at line 383 of file CopyModifyMergeRepositoryTool.py.

00383 
00384                    countPurged=True):
00385         """See IPurgeSupport.
00386         """
00387         self._assertAuthorized(obj, AccessPreviousVersions, 'getHistory')
00388         return LazyHistory(self, obj, oldestFirst, preserve, countPurged)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 241 of file CopyModifyMergeRepositoryTool.py.

00241 
00242     def getPolicyMap(self):
00243         return dict(self._version_policy_mapping)

Here is the call graph for this function:

Definition at line 126 of file CopyModifyMergeRepositoryTool.py.

00126 
00127     def getVersionableContentTypes(self):
00128         return self._versionable_content_types

Here is the caller graph for this function:

Definition at line 169 of file CopyModifyMergeRepositoryTool.py.

00169 
00170     def hasPolicy(self, obj):
00171         content_type = obj.portal_type
00172         return bool(self._version_policy_mapping.get(content_type, None))

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

Definition at line 390 of file CopyModifyMergeRepositoryTool.py.

00390 
00391     def isUpToDate(self, obj, selector=None, countPurged=True):
00392         """See IPurgeSupport.
00393         """
00394         portal_archivist = getToolByName(self, 'portal_archivist')
00395         return portal_archivist.isUpToDate(obj=obj, selector=selector,
00396                                            countPurged=countPurged)
00397 

Here is the call graph for this function:

See interface.

Definition at line 120 of file CopyModifyMergeRepositoryTool.py.

00120 
00121     def isVersionable(self, obj):
00122         """See interface.
00123         """
00124         return obj.portal_type in self.getVersionableContentTypes()

Here is the call graph for this function:

Definition at line 188 of file CopyModifyMergeRepositoryTool.py.

00188 
00189     def listPolicies(self):
00190         # convert the internal dict into a sequence of tuples
00191         # sort on title
00192         policy_list = [(p.Title(), p) for p in self._policy_defs.values()]
00193         policy_list.sort()
00194         policy_list = [p for (title, p) in policy_list]
00195         return policy_list

Here is the call graph for this function:

Definition at line 210 of file CopyModifyMergeRepositoryTool.py.

00210 
00211     def manage_changePolicyDefs(self, policy_list, **kwargs):
00212         # Call remove hooks for existing policies
00213         p_defs = self._policy_defs
00214         for policy_id in list(p_defs.keys()):
00215             self.removePolicy(policy_id, **kwargs)
00216         # Verify proper input formatting
00217         assert isinstance(policy_list, list) or isinstance(policy_list, tuple)
00218         for item in policy_list:
00219             assert isinstance(item, tuple), \
00220                         "List items must be tuples: %s"%str(item)
00221             assert len(item) in (2,3,4), \
00222             "Each policy definition must contain a title and id: %s"%str(item)
00223             assert isinstance(item[0], basestring), \
00224                         "Policy id must be a string: %s"%str(item[0])
00225             assert isinstance(item[1], basestring), \
00226                         "Policy title must be a string: %s"%str(item[1])
00227             # Get optional Policy class and kwargs.
00228             if len(item)>=3:
00229                 policy_class = item[2]
00230             else:
00231                 policy_class = VersionPolicy
00232             if len(item)==4:
00233                 assert isinstance(item[3], dict), \
00234                                 "Extra args for %s must be a dict"%item[0]
00235                 kw = item[3]
00236             else:
00237                 kw = kwargs
00238             # Add new policy
00239             self.addPolicy(item[0],item[1],policy_class,**kw)

Here is the call graph for this function:

Definition at line 174 of file CopyModifyMergeRepositoryTool.py.

00174 
00175     def manage_setTypePolicies(self, policy_map, **kw):
00176         assert isinstance(policy_map, dict)
00177         for p_type, policies in self._version_policy_mapping.items():
00178             for policy_id in policies:
00179                 self.removePolicyFromContentType(p_type, policy_id, **kw)
00180         for p_type, policies in policy_map.items():
00181             assert isinstance(policies, list), \
00182                             "Policy list for %s must be a list"%str(p_type)
00183             for policy_id in policies:
00184                 assert self._policy_defs.has_key(policy_id), \
00185                                   "Policy %s is unknown"%policy_id
00186                 self.addPolicyForContentType(p_type, policy_id, **kw)

Here is the call graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool.purge (   self,
  obj,
  selector,
  comment = "",
  metadata = {},
  countPurged = True 
)
See IPurgeSupport.

Definition at line 303 of file CopyModifyMergeRepositoryTool.py.

00303 
00304     def purge(self, obj, selector, comment="", metadata={}, countPurged=True):
00305         """See IPurgeSupport.
00306         """
00307         self._assertAuthorized(obj, PurgeVersion, 'purge')
00308         
00309         # Trying to avoid mess with purged versions which we don't offer
00310         # support yet when passed to the repository layer due to a missing
00311         # purge policy. The problem would occure on revert and retrieve.
00312         pp = getToolByName(self, 'portal_purgepolicy', None)
00313         if pp is None:
00314             raise RepositoryPurgeError("Purging a version is not possible. "
00315                                        "Purge is only possible with a purge "
00316                                        "policy installed.")
00317 
00318         portal_archivist = getToolByName(self, 'portal_archivist')
00319         # just hand over to the archivist for the moment (recursive purging
00320         # may be implemented in a future release)
00321         metadata = {
00322             "app_metadata": metadata,
00323             "sys_metadata": self._prepareSysMetadata(comment),
00324         }
00325         portal_archivist.purge(obj=obj, selector=selector,
00326                                metadata=metadata, countPurged=countPurged)

Here is the call graph for this function:

Definition at line 203 of file CopyModifyMergeRepositoryTool.py.

00203 
00204     def removePolicy(self, policy_id, **kw):
00205         for p_type in self._version_policy_mapping.keys():
00206             self.removePolicyFromContentType(p_type, policy_id, **kw)
00207         self._callPolicyHook('remove', policy_id, **kw)
00208         del self._policy_defs[policy_id]

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 149 of file CopyModifyMergeRepositoryTool.py.

00149 
00150     def removePolicyFromContentType(self, content_type, policy_id, **kw):
00151         policies = self._version_policy_mapping.copy()
00152         cur_policy = policies.setdefault(content_type, [])
00153         if policy_id in cur_policy:
00154             cur_policy.remove(policy_id)
00155             self._callPolicyHook('disable', policy_id, content_type, **kw)
00156         self._version_policy_mapping = policies

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool.restore (   self,
  history_id,
  selector,
  container,
  new_id = None,
  countPurged = True 
)
See IPurgeSupport.

Definition at line 357 of file CopyModifyMergeRepositoryTool.py.

00357 
00358                 countPurged=True):
00359         """See IPurgeSupport.
00360         """
00361 
00362         self._assertAuthorized(container, RevertToPreviousVersions, 'revert')
00363         fixup_queue = []
00364         vdata = self._recursiveRetrieve(history_id=history_id,
00365                                         selector=selector, inplace=True,
00366                                         source=container,
00367                                         fixup_queue=fixup_queue,
00368                                         ignore_existing=True,
00369                                         countPurged=countPurged)
00370 
00371         # Set the id to the desired value
00372         orig_id = vdata.data.object.getId()
00373         if new_id and orig_id != new_id:
00374             # Make sure we have a _p_jar
00375             transaction.savepoint()
00376             container.manage_renameObject(orig_id, new_id)
00377             #parent._setObject(original_id, obj, set_owner=0)
00378 
00379         # run fixups
00380         self._doInplaceFixups(fixup_queue, True)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 349 of file CopyModifyMergeRepositoryTool.py.

00349 
00350     def retrieve(self, obj, selector=None, preserve=(), countPurged=True):
00351         """See IPurgeSupport.
00352         """
00353         self._assertAuthorized(obj, AccessPreviousVersions, 'retrieve')
00354         return self._retrieve(obj, selector, preserve, countPurged)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool.revert (   self,
  obj,
  selector = None,
  countPurged = True 
)
See IPurgeSupport.

Definition at line 328 of file CopyModifyMergeRepositoryTool.py.

00328 
00329     def revert(self, obj, selector=None, countPurged=True):
00330         """See IPurgeSupport.
00331         """
00332         # XXX this should go away if _recursiveRetrieve is correctly implemented
00333         original_id = obj.getId()
00334 
00335         self._assertAuthorized(obj, RevertToPreviousVersions, 'revert')
00336         fixup_queue = []
00337         self._recursiveRetrieve(obj=obj, selector=selector, inplace=True, 
00338                                 fixup_queue=fixup_queue, 
00339                                 countPurged=countPurged)
00340         # XXX this should go away if _recursiveRetrieve is correctly implemented
00341         if obj.getId() != original_id:
00342             obj._setId(original_id)
00343             #parent.manage_renameObject(obj.getId(), original_id)
00344             #parent._setObject(original_id, obj, set_owner=0)
00345 
00346         # run fixups
00347         self._doInplaceFixups(fixup_queue, True)

Here is the call graph for this function:

def CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool.save (   self,
  obj,
  comment = '',
  metadata = {} 
)
See ICopyModifyMergeRepository.

Definition at line 284 of file CopyModifyMergeRepositoryTool.py.

00284 
00285     def save(self, obj, comment='', metadata={}):
00286         """See ICopyModifyMergeRepository.
00287         """
00288         self._assertAuthorized(obj, SaveNewVersion, 'save')
00289         sp = transaction.savepoint(optimistic=True)
00290         try:
00291             self._recursiveSave(obj, metadata,
00292                                 self._prepareSysMetadata(comment),
00293                                 autoapply=self.autoapply)
00294         except ModifierException:
00295             # modifiers can abort save operations under certain conditions
00296             sp.rollback()
00297             raise

Here is the call graph for this function:

Here is the caller graph for this function:

See ICopyModifyMergeRepository.

Definition at line 263 of file CopyModifyMergeRepositoryTool.py.

00263 
00264     def setAutoApplyMode(self, autoapply):
00265         """See ICopyModifyMergeRepository.
00266         """
00267         self.autoapply = autoapply

Definition at line 130 of file CopyModifyMergeRepositoryTool.py.

00130 
00131     def setVersionableContentTypes(self, new_content_types):
00132         self._versionable_content_types = new_content_types

Definition at line 158 of file CopyModifyMergeRepositoryTool.py.

00158 
00159     def supportsPolicy(self, obj, policy):
00160         content_type = obj.portal_type
00161         # in 1.0alpha3 and earlier ``version_on_revert`` was 
00162         # ``version_on_rollback``. Convert to new name.
00163         config = self._version_policy_mapping.get(content_type, [])
00164         if "version_on_rollback" in config:
00165             config[config.index("version_on_rollback")] = "version_on_revert"
00166         
00167         return policy in self._version_policy_mapping.get(content_type, [])


Member Data Documentation

Initial value:
(
        SimpleItem.__implements__,
        IPurgeSupport, 
        ICopyModifyMergeRepository,
        IContentTypeVersionPolicySupport,
        )

Definition at line 83 of file CopyModifyMergeRepositoryTool.py.

Definition at line 103 of file CopyModifyMergeRepositoryTool.py.

Definition at line 102 of file CopyModifyMergeRepositoryTool.py.

Definition at line 101 of file CopyModifyMergeRepositoryTool.py.

Definition at line 91 of file CopyModifyMergeRepositoryTool.py.

Definition at line 95 of file CopyModifyMergeRepositoryTool.py.

Definition at line 90 of file CopyModifyMergeRepositoryTool.py.

Definition at line 99 of file CopyModifyMergeRepositoryTool.py.

string CMFEditions.CopyModifyMergeRepositoryTool.CopyModifyMergeRepositoryTool.meta_type = 'CMFEditions Standard Copy Modify Merge Repository' [static]

Definition at line 93 of file CopyModifyMergeRepositoryTool.py.

Definition at line 97 of file CopyModifyMergeRepositoryTool.py.

Definition at line 136 of file CopyModifyMergeRepositoryTool.py.


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