[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - bundle.py:1.2

Guido van Rossum guido@python.org
Mon, 16 Jun 2003 12:58:59 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv15264

Modified Files:
	bundle.py 
Log Message:
Sort the "Services" service first.


=== Zope3/src/zope/app/browser/services/bundle.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/services/bundle.py:1.1	Mon Jun 16 12:00:37 2003
+++ Zope3/src/zope/app/browser/services/bundle.py	Mon Jun 16 12:58:59 2003
@@ -83,10 +83,10 @@
     def compareConfigurations(self, c1, c2):
         path1, obj1 = c1
         path2, obj2 = c2
-        t1 = (self.getServiceName(obj1),
+        t1 = (self.getAdjustedServiceName(obj1),
               obj1.usageSummary(),
               obj1.implementationSummary())
-        t2 = (self.getServiceName(obj2),
+        t2 = (self.getAdjustedServiceName(obj2),
               obj2.usageSummary(),
               obj2.implementationSummary())
         return cmp(t1, t2)
@@ -96,8 +96,22 @@
         for path, obj in self.configurations:
             sd[self.getServiceName(obj)] = 1
         services = sd.keys()
-        services.sort()
+        services.sort(self.compareServiceNames)
         return services
+
+    def compareServiceNames(self, n1, n2):
+        return cmp(self.adjustServiceName(n1), self.adjustServiceName(n2))
+
+    def getAdjustedServiceName(self, configuration):
+        name = self.getServiceName(configuration)
+        return self.adjustServiceName(name)
+
+    def adjustServiceName(self, name):
+        # XXX Strange...  There's no synbol for it in servicenames.py
+        if name == "Services":
+            return ""
+        else:
+            return name
 
     def getServiceName(self, configuration):
         # Return the service associated with a configuration.