declare namespace and schema location
[sfa.git] / sfa / trust / credential.py
index 45c34f8..4a1d755 100644 (file)
@@ -39,7 +39,7 @@ from sfa.util.sfalogging import logger
 from sfa.util.sfatime import utcparse
 from sfa.trust.certificate import Keypair
 from sfa.trust.credential_legacy import CredentialLegacy
-from sfa.trust.rights import Right, Rights
+from sfa.trust.rights import Right, Rights, determine_rights
 from sfa.trust.gid import GID
 from sfa.util.xrn import urn_to_hrn
 
@@ -348,7 +348,7 @@ class Credential(object):
     # Expiration: an absolute UTC time of expiration (as either an int or string or datetime)
     # 
     def set_expiration(self, expiration):
-        if isinstance(expiration, int):
+        if isinstance(expiration, (int,float)):
             self.expiration = datetime.datetime.fromtimestamp(expiration)
         elif isinstance (expiration, datetime.datetime):
             self.expiration = expiration
@@ -423,9 +423,11 @@ class Credential(object):
 # But it's kind of odd for PL to use PG schemas that talk
 # about tickets, and the PG CM policies.
 # Note the careful addition of attributes from the parent below...
-#        signed_cred.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
+        signed_cred.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
 #        signed_cred.setAttribute("xsinoNamespaceSchemaLocation", "http://www.protogeni.net/resources/credential/credential.xsd")
 #        signed_cred.setAttribute("xsi:schemaLocation", "http://www.protogeni.net/resources/credential/ext/policy/1 http://www.protogeni.net/resources/credential/ext/policy/1/policy.xsd")
+        signed_cred.setAttribute("xsinoNamespaceSchemaLocation", "http://www.planet-lab.org/resources/sfa/credential.xsd")
+        signed_cred.setAttribute("xsi:schemaLocation", "http://www.planet-lab.org/resources/sfa/ext/policy/1 http://www.planet-lab.org/resources/sfa/ext/policy.xsd")
 
         doc.appendChild(signed_cred)  
         
@@ -662,7 +664,7 @@ class Credential(object):
                 # Convert * into the default privileges for the credential's type
                 # Each inherits the delegatability from the * above
                 _ , type = urn_to_hrn(self.gidObject.get_urn())
-                rl = rlist.determine_rights(type, self.gidObject.get_urn())
+                rl = determine_rights(type, self.gidObject.get_urn())
                 for r in rl.rights:
                     r.delegate = deleg
                     rlist.add(r)
@@ -965,6 +967,6 @@ class Credential(object):
 
         if self.parent and dump_parents:
             result += "\nPARENT"
-            result += self.parent.dump(True)
+            result += self.parent.dump_string(True)
 
         return result