merge in rspec_extensions branch
[sfa.git] / sfa / rspecs / rspec.py
index fe80006..35aa202 100755 (executable)
@@ -10,19 +10,25 @@ from sfa.util.faults import SfaNotImplemented, InvalidRSpec
 class RSpec:
     header = '<?xml version="1.0"?>\n'
     template = """<RSpec></RSpec>"""
-    namespaces = {}
     config = Config()
     xml = None
     type = None
-    version = None     
+    version = None
+    namespaces = None
+    user_options = {}
   
-    def __init__(self, rspec="", namespaces={}):
+    def __init__(self, rspec="", namespaces={}, type=None, user_options={}:
+        self.type = type
+        self.user_options = user_options
         if rspec:
             self.parse_rspec(rspec, namespaces)
         else:
             self.create()
 
-    def create(self, type="advertisement"):
+    def __get_template(self):
+        return self.template
+
+    def create(self):
         """
         Create root element
         """
@@ -31,7 +37,7 @@ class RSpec:
         now = datetime.utcnow()
         generated_ts = now.strftime(date_format)
         expires_ts = (now + timedelta(hours=1)).strftime(date_format) 
-        self.parse_rspec(self.template, self.namespaces)
+        self.parse_rspec(self.__get_template, self.namespaces)
         self.xml.set('valid_until', expires_ts)
         self.xml.set('generated', generated_ts)
     
@@ -87,6 +93,8 @@ class RSpec:
                     if opt.text == value:
                         elem.remove(opt)
 
+    def merge(self, in_rspec):
+        pass
 
     def validate(self, schema):
         """