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

## Source Code for Module bootstrap

     1
     2  # We need some objects that don't need configuring in order to bootstrap
     3  # Eg:  Need a parser to parser the configuration files for parsers!
     4  # (Also to avoid import errors in Python)
     5
     6  from xml.dom.minidom import parseString
     7
     8 -class BootstrapParser:
     9
    10 -    def process_document(self, session, doc):
    11          xml = doc.get_raw()
    12          dom = parseString(xml)
    13          rec = BootstrapRecord(dom, xml)
    14          return rec
    15
    16 -class BootstrapRecord:
    17      xml = ""
    18      dom = None
    19
    20
    21 -    def __init__(self, dom, xml):
    22          self.dom = dom
    23          self.xml = xml
    24
    25 -    def get_dom(self):
    26          return self.dom
    27
    28 -    def get_xml(self):
    29          return self.xml
    30
    31 -    def get_sax(self):
    32          raise(NotImplementedError)
    33
    34 -class BootstrapDocument:
    35      handle = None
    36      txt = ""
    37
    38 -    def __init__(self, fileHandle):
    39          # This means we have hanging file handles, but less memory usage...
    40          self.handle = fileHandle
    41
    42 -    def get_raw(self):
    43          if (self.txt):
    44              return self.txt
    45          elif (self.handle <> None):
    46              self.txt =  self.handle.read()
    47              self.handle.close()
    48              return self.txt
    49          else:
    50              return None
    51
    52  # admin that can do anything
    53 -class BootstrapUser:
    54      username = "admin"
    55      password = ""
    56      flags = {'' : 'c3r:administrator'}
    57
    58 -    def hasFlag(self, session, flag, object=""):
    59          return True
    60
    61 -class BootstrapSession:
    62      user = None
    63      inHandler = None
    64      outHandler = None
    65 -    def __init__(self):
    66          self.user = BootstrapUser()
    67
    68  BSParser = BootstrapParser()
    69  BSSession = BootstrapSession()
    70