Back to index

plone3  3.1.7
Private Member Functions
GenericSetup.utils.ObjectManagerHelpers Class Reference

List of all members.

Private Member Functions

def _extractObjects
def _purgeObjects
def _initObjects

Detailed Description

ObjectManager im- and export helpers.

Definition at line 557 of file utils.py.


Member Function Documentation

Definition at line 562 of file utils.py.

00562 
00563     def _extractObjects(self):
00564         fragment = self._doc.createDocumentFragment()
00565         objects = self.context.objectValues()
00566         if not IOrderedContainer.providedBy(self.context):
00567             objects = list(objects)
00568             objects.sort(lambda x,y: cmp(x.getId(), y.getId()))
00569         for obj in objects:
00570             exporter = queryMultiAdapter((obj, self.environ), INode)
00571             if exporter:
00572                 node = exporter.node
00573                 if node is not None:
00574                     fragment.appendChild(exporter.node)
00575         return fragment

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.utils.ObjectManagerHelpers._initObjects (   self,
  node 
) [private]

Definition at line 582 of file utils.py.

00582 
00583     def _initObjects(self, node):
00584         for child in node.childNodes:
00585             if child.nodeName != 'object':
00586                 continue
00587             if child.hasAttribute('deprecated'):
00588                 continue
00589             parent = self.context
00590 
00591             obj_id = str(child.getAttribute('name'))
00592             if child.hasAttribute('remove'):
00593                 if obj_id in parent.objectIds():
00594                     parent._delObject(obj_id)
00595                 continue
00596 
00597             if obj_id not in parent.objectIds():
00598                 meta_type = str(child.getAttribute('meta_type'))
00599                 __traceback_info__ = obj_id, meta_type
00600                 for mt_info in Products.meta_types:
00601                     if mt_info['name'] == meta_type:
00602                         parent._setObject(obj_id, mt_info['instance'](obj_id))
00603                         break
00604                 else:
00605                     raise ValueError("unknown meta_type '%s'" % meta_type)
00606 
00607             if child.hasAttribute('insert-before'):
00608                 insert_before = child.getAttribute('insert-before')
00609                 if insert_before == '*':
00610                     parent.moveObjectsToTop(obj_id)
00611                 else:
00612                     try:
00613                         position = parent.getObjectPosition(insert_before)
00614                         if parent.getObjectPosition(obj_id) < position:
00615                             position -= 1
00616                         parent.moveObjectToPosition(obj_id, position)
00617                     except ValueError:
00618                         pass
00619             elif child.hasAttribute('insert-after'):
00620                 insert_after = child.getAttribute('insert-after')
00621                 if insert_after == '*':
00622                     parent.moveObjectsToBottom(obj_id)
00623                 else:
00624                     try:
00625                         position = parent.getObjectPosition(insert_after)
00626                         if parent.getObjectPosition(obj_id) < position:
00627                             position -= 1
00628                         parent.moveObjectToPosition(obj_id, position+1)
00629                     except ValueError:
00630                         pass
00631 
00632             obj = getattr(self.context, obj_id)
00633             importer = queryMultiAdapter((obj, self.environ), INode)
00634             if importer:
00635                 importer.node = child
00636 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 576 of file utils.py.

00576 
00577     def _purgeObjects(self):
00578         for obj_id, obj in self.context.objectItems():
00579             if ISetupTool.providedBy(obj):
00580                 continue
00581             self.context._delObject(obj_id)

Here is the caller graph for this function:


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