[Zope3-checkins] CVS: Zope3/src/zope/app/services - folder.py:1.1 pagefolder.py:1.1 configure.zcml:1.22 service.py:1.15 package.py:NONE viewpackage.py:NONE

Jim Fulton jim@zope.com
Sun, 23 Mar 2003 11:46:15 -0500


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

Modified Files:
	configure.zcml service.py 
Added Files:
	folder.py pagefolder.py 
Removed Files:
	package.py viewpackage.py 
Log Message:
Renamed "packages" to "site-management folders".
Reanemd "view sub-packages" to "page folders".


=== Added File Zope3/src/zope/app/services/folder.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""A package contains components and component configurations.

$Id: folder.py,v 1.1 2003/03/23 16:45:44 jim Exp $
"""

__metaclass__ = type

from zope.app.component.nextservice import getNextServiceManager
from zope.app.container.btree import BTreeContainer
from zope.app.interfaces.services.folder import ISiteManagementFolders
from zope.app.interfaces.services.folder import ISiteManagementFolder
from zope.app.interfaces.services.service import IComponentManager
from zope.app.interfaces.services.service import IServiceManager
from zope.app.services.configuration import ConfigurationManager
from zope.app.traversing import getPath
from zope.proxy.context import ContextMethod, ContextWrapper

class SiteManagementFolder(BTreeContainer):
    __implements__ = ISiteManagementFolder

    def __init__(self):
        super(SiteManagementFolder, self).__init__()
        self.setObject('configure', ConfigurationManager())

class SiteManagementFolders(BTreeContainer):
    __implements__ = ISiteManagementFolders

    def __init__(self):
        super(SiteManagementFolders, self).__init__()
        self.setObject('default', SiteManagementFolder())

    def queryComponent(self, type=None, filter=None, all=0):
        local = []
        path = getPath(self)
        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
                wrapper =  ContextWrapper(component, package, name=name)
                local.append({'path': "%s/%s/%s" % (path, pkg_name, name),
                              'component': wrapper,
                              })

        if all:
            next_service_manager = getNextServiceManager(self)
            if IComponentManager.isImplementedBy(next_service_manager):
                next_service_manager.queryComponent(type, filter, all)

            local += list(all)

        return local

    queryComponent = ContextMethod(queryComponent)

    def setObject(self, name, obj):
        if not ISiteManagementFolder.isImplementedBy(obj):
            raise TypeError("Can only add packages")
        return super(SiteManagementFolders, self).setObject(name, obj)

# XXX Backward compatability. This is needed to support old pickles.
Package = SiteManagementFolder
Packages = SiteManagementFolders
import sys
sys.modules['zope.app.services.package'
            ] = sys.modules['zope.app.services.folder']


=== Added File Zope3/src/zope/app/services/pagefolder.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Page Folders

Page folders support easy creation and configuration of page views
using folders of templates.

$Id: pagefolder.py,v 1.1 2003/03/23 16:45:44 jim Exp $
"""
__metaclass__ = type

from zope.app.container.btree import BTreeContainer
from zope.app.interfaces.services.view import IZPTTemplate
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.app.traversing import getPath, traverse
from zope.proxy.context import getItem, getAttr
from zope.proxy.context import ContextMethod
from zope.app.interfaces.services.configuration import Active
from zope.app.services.configuration import ConfigurationManager
from zope.app.services.configuration import ConfigurationStatusProperty
from zope.proxy.introspection import removeAllProxies
from zope.app.services.view import PageConfiguration
from zope.app.interfaces.services.pagefolder import IPageFolder

class PageFolder(BTreeContainer):

    __implements__ = IPageFolder

    presentationType = IBrowserPresentation
    layer = "default"
    description = ''
    title = ''
    factoryName = None
    attribute = None
    template = None

    def __init__(self):
        super(PageFolder, self).__init__()
        super(PageFolder, self).setObject('configure', ConfigurationManager())

    def setObject(self, name, object):
        if not IZPTTemplate.isImplementedBy(object):
            raise TypeError("Can only add templates", object)

        # super() does not work on a context wrapped instance
        base = removeAllProxies(self)

        name = super(PageFolder, base).setObject(name, object)
        template = getItem(self, name)
        template = getPath(template)
        config = PageConfiguration(
            forInterface=self.forInterface,
            viewName=name,
            permission=self.permission,
            class_=self.factoryName,
            template=template,
            layer=self.layer,
            )
        configure = traverse(self, 'configure')
        id = configure.setObject('', config)
        config = getItem(configure, id)
        config.status = Active
        return name

    setObject = ContextMethod(setObject)

    def configured(self):
        return (hasattr(self, 'permission')
                and hasattr(self, 'forInterface')
                )

    def activated(self):
        "See IConfiguration"

    def deactivated(self):
        "See IConfiguration"

# XXX Backward compatability. This is needed to support old pickles.
ViewPackage = PageFolder
import sys
sys.modules['zope.app.services.viewpackage'
            ] = sys.modules['zope.app.services.pagefolder']


=== Zope3/src/zope/app/services/configure.zcml 1.21 => 1.22 ===
--- Zope3/src/zope/app/services/configure.zcml:1.21	Fri Mar 21 16:02:19 2003
+++ Zope3/src/zope/app/services/configure.zcml	Sun Mar 23 11:45:44 2003
@@ -112,7 +112,7 @@
   />
 
 <adapter
-  for="zope.app.interfaces.services.service.IViewPackage"
+  for="zope.app.interfaces.services.pagefolder.IPageFolder"
   provides="zope.app.interfaces.file.IFileFactory"
   factory=".zpt.ZPTFactory"
   permission="zope.ManageServices"
@@ -229,9 +229,9 @@
 
   </content>
 
-<!-- Packages -->
+<!-- SiteManagementFolders -->
 
-  <content class="zope.app.services.package.Packages">
+  <content class="zope.app.services.folder.SiteManagementFolders">
     <require
         permission="zope.View"
         interface="zope.app.interfaces.container.IReadContainer" />
@@ -246,7 +246,7 @@
 
     </content>
 
-  <content class="zope.app.services.package.Package">
+  <content class="zope.app.services.folder.SiteManagementFolder">
     <require
         permission="zope.View"
         interface="zope.app.interfaces.container.IReadContainer" />
@@ -293,11 +293,11 @@
         />
   </content>
 
-<!-- View Packages -->
+<!-- Page Folder -->
 
-  <content class="zope.app.services.viewpackage.ViewPackage">
+  <content class="zope.app.services.pagefolder.PageFolder">
     <factory
-      id = "zope.app.services.ViewPackage"
+      id = "zope.app.services.PageFolder"
       permission = "zope.ManageServices"
       title = "View Folder"
       />
@@ -306,12 +306,9 @@
         interface="zope.app.interfaces.container.IReadContainer" />
     <require
         permission="zope.ManageServices"
-        interface="zope.app.interfaces.container.IWriteContainer"
-        set_schema="zope.app.interfaces.services.service.IViewPackageInfo"
-        />
-    <require
-        permission="zope.ManageServices"
-        interface="zope.app.interfaces.services.service.IViewPackageInfo"
+        interface="zope.app.interfaces.container.IWriteContainer
+                   zope.app.interfaces.services.pagefolder.IPageFolderInfo"
+        set_schema="zope.app.interfaces.services.pagefolder.IPageFolderInfo"
         attributes="configured"
         />
     <implements


=== Zope3/src/zope/app/services/service.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/services/service.py:1.14	Wed Mar 19 14:57:31 2003
+++ Zope3/src/zope/app/services/service.py	Sun Mar 23 11:45:44 2003
@@ -57,7 +57,7 @@
 from zope.app.services.configuration import ConfigurationStatusProperty
 from zope.app.services.configuration import NameComponentConfigurable
 from zope.app.services.configuration import NamedComponentConfiguration
-from zope.app.services.package import Packages
+from zope.app.services.folder import SiteManagementFolders
 from zope.app.interfaces.services.configuration import IUseConfigurable
 from zope.app.interfaces.services.service import ILocalService
 
@@ -73,7 +73,7 @@
     def __init__(self):
         super(ServiceManager, self).__init__()
         NameComponentConfigurable.__init__(self)
-        self.Packages = Packages()
+        self.Packages = SiteManagementFolders()
 
     def getServiceDefinitions(wrapped_self):
         "See IServiceService"
@@ -186,7 +186,6 @@
 
         return self.get(key) is not None
 
-    # Enumeration methods. We'll only expose Packages for now:
     def __iter__(self):
         return iter(self.keys())
 

=== Removed File Zope3/src/zope/app/services/package.py ===

=== Removed File Zope3/src/zope/app/services/viewpackage.py ===