Back to index

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

List of all members.

Public Member Functions

def getReferencedAttributes
def getOnCloneModifiers
def beforeSaveModifier
def afterRetrieveModifier
def reattachReferencedAttributes
def getId

Static Public Attributes

string id = 'portal_modifier'

Private Member Functions

def _getAttributeNamesHandlingSubObjects

Static Private Attributes

tuple __implements__ = ()

Detailed Description

This is a full fledged modifier.

Definition at line 283 of file DummyTools.py.


Member Function Documentation

Definition at line 380 of file DummyTools.py.

00380 
00381     def _getAttributeNamesHandlingSubObjects(self, obj):
00382         return ['_objects'].extend(obj.objectIds())
00383 

Here is the caller graph for this function:

def CMFEditions.tests.DummyTools.FolderishContentObjectModifier.afterRetrieveModifier (   self,
  obj,
  repo_clone,
  preserve = () 
)

Definition at line 366 of file DummyTools.py.

00366 
00367     def afterRetrieveModifier(self, obj, repo_clone, preserve=()):
00368         preserved = {}
00369         # just a dead simple test implementation
00370         for key in preserve:
00371             preserved[key] = key
00372 
00373         ref_names = self._getAttributeNamesHandlingSubObjects(obj)
00374         return [], ref_names, {}

Here is the call graph for this function:

Returns all unititialized 'IVersionAwareReference' objects.

This allways goes in conjunction with 'getOnCloneModifiers'.

Definition at line 346 of file DummyTools.py.

00346 
00347     def beforeSaveModifier(self, obj, clone):
00348         """Returns all unititialized 'IVersionAwareReference' objects.
00349 
00350         This allways goes in conjunction with 'getOnCloneModifiers'.
00351         """
00352         portal_archivist = getToolByName(obj, 'portal_archivist')
00353         AttributeAdapter = portal_archivist.classes.AttributeAdapter
00354 
00355         # just return adapters to the attributes that were replaced by
00356         # a uninitialzed 'IVersionAwareReference' object
00357         outside_refs = []
00358         inside_refs = []
00359         for name in clone.objectIds():
00360             if name.endswith('_inside'):
00361                 inside_refs.append(AttributeAdapter(clone, name))
00362             elif name.endswith('_outside'):
00363                 outside_refs.append(AttributeAdapter(clone, name))
00364 
00365         return {}, inside_refs, outside_refs

Here is the call graph for this function:

Definition at line 33 of file DummyTools.py.

00033 
00034     def getId(self):
00035         return self.id

Here is the call graph for this function:

Removes childrens ending with '_inside' or '_outside'.

Just replaces object manager sub objects ending '_inside' or
'_outside' by a uninitialzed 'IVersionAwareReference'.
All other childrens get versioned with the parent.

Definition at line 295 of file DummyTools.py.

00295 
00296     def getOnCloneModifiers(self, obj):
00297         """Removes childrens ending with '_inside' or '_outside'.
00298 
00299         Just replaces object manager sub objects ending '_inside' or
00300         '_outside' by a uninitialzed 'IVersionAwareReference'.
00301         All other childrens get versioned with the parent.
00302         """
00303         portal_archivist = getToolByName(obj, 'portal_archivist')
00304         VersionAwareReference = portal_archivist.classes.VersionAwareReference
00305 
00306         # do not pickle the object managers subobjects
00307         refs = {}
00308         outside_refs = []
00309         inside_refs = []
00310         for name, sub in obj.objectItems():
00311             pyid = id(aq_base(sub))
00312             if name.endswith('_inside'):
00313                 inside_refs.append(sub)
00314                 refs[pyid] = True
00315             elif name.endswith('_outside'):
00316                 outside_refs.append(sub)
00317                 refs[pyid] = True
00318 
00319         # do not pickle the big blob attributes
00320         base_obj = aq_base(obj)
00321         for attr in self.getReferencedAttributes(obj).keys():
00322             try:
00323                 pyid = id(getattr(base_obj, attr))
00324             except AttributeError:
00325                 pass
00326             else:
00327                 refs[pyid] = False
00328 
00329         def persistent_id(obj):
00330             if id(obj) in refs:
00331                 return id(obj)
00332             return None
00333 
00334         def persistent_load(pid):
00335             if pid in refs:
00336                 if refs[pid]:
00337                     # references
00338                     return VersionAwareReference()
00339                 else:
00340                     # just directly passed attributes
00341                     return None
00342             # should never reach this!
00343             assert False
00344 
00345         return persistent_id, persistent_load, inside_refs, outside_refs, ''

Here is the call graph for this function:

Definition at line 290 of file DummyTools.py.

00290 
00291     def getReferencedAttributes(self, obj):
00292         # we declare the title beeing a big blob we don't want to be
00293         # pickled and unpickled by the archivist
00294         return {'title': obj.title}

Here is the caller graph for this function:

Definition at line 375 of file DummyTools.py.

00375 
00376     def reattachReferencedAttributes(self, object, referenced_data):
00377         # just a dead simple test implementation
00378         for key, value in referenced_data.items():
00379             setattr(object, key, value)


Member Data Documentation

Definition at line 287 of file DummyTools.py.

Definition at line 288 of file DummyTools.py.


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