update a urn's type in Xrn.__init__()
[sfa.git] / sfa / util / xrn.py
index e548fa5..9a5740c 100644 (file)
@@ -124,13 +124,17 @@ class Xrn:
             self.hrn=None
             self.urn=xrn
             if id:
-                self.urn = "%s:%s" % (self.urn, str(id))
+                self.urn = "%s-%s" % (self.urn, str(id))
             self.urn_to_hrn()
+            if type:
+                self.type=type
+                self.hrn_to_urn()
         else:
             self.urn=None
             self.hrn=xrn
             self.type=type
             self.hrn_to_urn()
+
         self._normalize()
 # happens all the time ..
 #        if not type:
@@ -173,11 +177,7 @@ class Xrn:
         update the authority section of an existing urn
         """
         authority_hrn = self.get_authority_hrn()
-        if not authority_hrn.startswith(authority):
-            hrn = ".".join([authority,authority_hrn, self.get_leaf()])
-        else:
-            hrn = ".".join([authority_hrn, self.get_leaf()])
-            
+        hrn = ".".join([authority, self.get_leaf()]) 
         self.hrn = hrn 
         self.hrn_to_urn()
         self._normalize()