objectStore

Module objectStore |
[hide private]
[frames] | no frames]

## Source Code for Module objectStore

     1
     2  from baseObjects import ObjectStore
     3  from configParser import C3Object
     4  from recordStore import BdbRecordStore
     5  from utils import getFirstData, elementType
     6  import dynamic
     7  from c3errors import ConfigFileException
     8
     9 -class BdbObjectStore(BdbRecordStore, ObjectStore):
    10      # Store XML records in RecordStore
    11      # Retrieve and instantiate
    12
    13      # NB Use create_record() to store configurations
    14 -    def create_object(self, session, object=None):
    15          # Need to implement object -> config xml for all objects!
    16          # Check doesn't exist, then call store_object
    17          raise(NotImplementedError)
    18
    19 -    def delete_object(self, session, id):
    20          return self.delete_record(session, id)
    21
    22 -    def fetch_object(self, session, id):
    23          rec = self.fetch_record(session, id)
    24          if (not rec):
    25              return None
    26
    27          dom = rec.get_dom()
    28          for d in dom.childNodes:
    29              if d.nodeType == elementType:
    30                  topNode = d
    31                  break
    32          # Need to import stuff first, possibly
    33          for child in topNode.childNodes:
    34              if child.nodeType == elementType:
    35                  if (child.localName == "imports"):
    36                      # Do this now so we can reference
    37                      for mod in child.childNodes:
    38                          if mod.nodeType == elementType and mod.localName == "module":
    39                              name, objects, withname = ('', [], None)
    40                              for n in mod.childNodes:
    41                                  if (n.nodeType == elementType):
    42                                      if (n.localName == 'name'):
    43                                          name = getFirstData(n)
    44                                      elif (n.localName == 'object'):
    45                                          objects.append(getFirstData(n))
    46                                      elif (n.localName == 'withName'):
    47                                          withname = getFirstData(n)
    48                              if (name):
    49                                  dynamic.globalImport(name, objects, withname)
    50                              else:
    51                                  raise(ConfigFileException('No name given for module to import in configFile for %s' % (self.id)))
    52
    53          object = dynamic.makeObjectFromDom(session, topNode, self)
    54          return object
    55
    56 -    def fetch_objectList(self, session, req):
    57          # Scan like interface?
    58          raise(NotImplementedError)
    59
    60 -    def store_object(self, session, object):
    61          raise(NotImplementedError)
    62