bug fix in importing sfa method modules
[sfa.git] / sfa / util / record.py
index ba3bd01..512381c 100644 (file)
@@ -15,9 +15,9 @@ import sfa.util.report
 from sfa.util.rspec import *
 from sfa.util.parameter import *
 from sfa.util.misc import *
+from sfa.util.row import Row
 
-
-class GeniRecord(dict):
+class GeniRecord(Row):
     """ 
     The GeniRecord class implements a Geni Record. A GeniRecord is a tuple
     (Hrn, GID, Type, Info).
@@ -37,9 +37,13 @@ class GeniRecord(dict):
     of different types.
     """
 
+    table_name = 'sfa'
+    
+    primary_key = 'record_id'
+
     ### the wsdl generator assumes this is named 'fields'
     internal_fields = {
-        'record_id': Parameter(int, 'An id that uniquely identifies this record'),
+        'record_id': Parameter(int, 'An id that uniquely identifies this record', ro=True),
         'pointer': Parameter(int, 'An id that uniquely identifies this record in an external database ')
     }
 
@@ -49,8 +53,8 @@ class GeniRecord(dict):
         'hrn': Parameter(str, "Human readable name of object"),
         'gid': Parameter(str, "GID of the object"),
         'type': Parameter(str, "Record type"),
-        'last_updated': Parameter(int, 'Date and time of last update'),
-        'date_created': Parameter(int, 'Date and time this record was created'),
+        'last_updated': Parameter(int, 'Date and time of last update', ro=True),
+        'date_created': Parameter(int, 'Date and time this record was created', ro=True),
     }
     all_fields = dict(fields.items() + internal_fields.items())
     ##
@@ -68,6 +72,7 @@ class GeniRecord(dict):
         self.gid = None
         self.type = None
         self.pointer = None
+        self.set_peer_auth(peer_authority)
         if hrn:
             self.set_name(hrn)
         if gid:
@@ -76,12 +81,14 @@ class GeniRecord(dict):
             self.set_type(type)
         if pointer:
             self.set_pointer(pointer)
-        if peer_authority:
-            self.set_peer_auth(peer_authority)
         if dict:
             self.load_from_dict(dict)
         if string:
             self.load_from_string(string)
+
+
+    def validate_last_updated(self, last_updated):
+        return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
         
     def update(self, new_dict):
         if isinstance(new_dict, list):