[Zope3-checkins] CVS: Zope3/src/zope/app/services - package.py:1.3

Jeremy Hylton jeremy@zope.com
Mon, 30 Dec 2002 15:42:47 -0500


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

Modified Files:
	package.py 
Log Message:
Cleanup packages modules.

Fiddle queryComponent() to avoid some extra-long lines.


=== Zope3/src/zope/app/services/package.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/services/package.py:1.2	Wed Dec 25 09:13:19 2002
+++ Zope3/src/zope/app/services/package.py	Mon Dec 30 15:42:46 2002
@@ -11,28 +11,31 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""XXX short summary goes here.
-
-XXX longer description goes here.
+"""A package contains components and component configurations.
 
 $Id$
 """
-__metaclass__ = type
 
+__metaclass__ = type
 
+from zope.app.component.nextservice import getNextServiceManager
 from zope.app.container.btree import BTreeContainer
+from zope.app.services.configurationmanager import ConfigurationManager
+from zope.app.traversing import getPhysicalPathString
+
 from zope.proxy.context import ContextMethod
 from zope.proxy.context import ContextWrapper
-from zope.app.traversing import getPhysicalPathString
-from zope.app.component.nextservice import getNextServiceManager
-from zope.app.interfaces.services.service \
-     import IServiceManager
+
 from zope.app.interfaces.services.service \
-     import IComponentManager
+     import IServiceManager, IComponentManager
+from zope.app.interfaces.services.package import IPackage, IPackages
 
-from zope.app.interfaces.services.package import IPackages
-from zope.app.interfaces.services.package import IPackage
+class Package(BTreeContainer):
+    __implements__ = IPackage
 
+    def __init__(self):
+        super(Package, self).__init__()
+        self.setObject('configure', ConfigurationManager())
 
 class Packages(BTreeContainer):
     __implements__ = IPackages
@@ -42,21 +45,19 @@
         self.setObject('default', Package())
 
     def queryComponent(self, type=None, filter=None, all=0):
-
         local = []
         path = getPhysicalPathString(self)
-        for package_name in self:
-            package = ContextWrapper(self[package_name], self,
-                                     name=package_name)
+        for pkg_name in self:
+            package = ContextWrapper(self[pkg_name], self, name=pkg_name)
             for name in package:
                 component = package[name]
                 if type is not None and not type.isImplementedBy(component):
                     continue
                 if filter is not None and not filter(component):
                     continue
-                local.append({'path': "%s/%s/%s" % (path, package_name, name),
-                              'component': ContextWrapper(component, package,
-                                                          name=name),
+                wrapper =  ContextWrapper(component, package, name=name)
+                local.append({'path': "%s/%s/%s" % (path, pkg_name, name),
+                              'component': wrapper,
                               })
 
         if all:
@@ -70,31 +71,8 @@
 
     queryComponent = ContextMethod(queryComponent)
 
-    def setObject(self, name, object):
-        if not IPackage.isImplementedBy(object):
+    def setObject(self, name, obj):
+        if not IPackage.isImplementedBy(obj):
             raise TypeError("Can only add packages")
-        return super(Packages, self).setObject(name, object)
-
-
+        return super(Packages, self).setObject(name, obj)
 
-
-"""XXX short summary goes here.
-
-XXX longer description goes here.
-
-$Id$
-"""
-__metaclass__ = type
-
-from zope.app.container.btree import BTreeContainer
-
-from zope.app.interfaces.services.package import IPackage
-from zope.app.services.configurationmanager import ConfigurationManager
-
-
-class Package(BTreeContainer):
-    __implements__ = IPackage
-
-    def __init__(self):
-        super(Package, self).__init__()
-        self.setObject('configure', ConfigurationManager())