[Zope3-checkins] CVS: Products3/bugtracker - exportimport.py:1.2

Stephan Richter srichter@cosmos.phy.tufts.edu
Sat, 26 Jul 2003 18:14:19 -0400


Update of /cvs-repository/Products3/bugtracker
In directory cvs.zope.org:/tmp/cvs-serv32415

Modified Files:
	exportimport.py 
Log Message:
Saving the principal id in the XML is totally useless. Use logins instead,


=== Products3/bugtracker/exportimport.py 1.1 => 1.2 ===
--- Products3/bugtracker/exportimport.py:1.1	Sat Jul 26 09:40:43 2003
+++ Products3/bugtracker/exportimport.py	Sat Jul 26 18:14:15 2003
@@ -105,7 +105,12 @@
         return self.context.priority
 
     def owners(self):
-        return ', '.join(self.context.owners)
+        # Principal ids are totally useless for exporting; use logins instead
+        registry = getVocabularyRegistry()
+        vocab = registry.get(self.context, 'Users')
+        owners = map(lambda o: vocab.getTerm(o).principal['login'],
+                     self.context.owners)
+        return ', '.join(owners)
 
     def dependencies(self):
         deps = getAdapter(self.context, IBugDependencies)
@@ -230,8 +235,17 @@
         bug.priority = attrs.get('priority')
         bug.type = attrs.get('type')
         bug.release = attrs.get('release')
-        owners = attrs.get('owners').split(', ')
-        bug.owners = filter(lambda o: o.strip() != u'', owners)
+
+        logins = attrs.get('owners').split(', ')
+        logins = filter(lambda o: o.strip() != u'', logins)
+        registry = getVocabularyRegistry()
+        vocab = registry.get(self.context, 'Users')
+        owners = []
+        for term in vocab:
+            if term.principal['login'] in logins:
+                owners.append(term.value)
+        bug.owners = owners
+
         deps_adapter = getAdapter(bug, IBugDependencies)
         deps = attrs.get('dependencies').split(', ')
         deps_adapter.setDependencies(filter(lambda o: o.strip() != u'', deps))