[Zope3-checkins] CVS: Zope3/src/zope/app/services -
adapter.py:1.22.6.1 configure.zcml:1.57.6.2
pagefolder.py:1.14.6.2 pagefolder.zcml:1.3.6.1
registration.py:1.16.6.2 surrogate.py:1.1.2.2 zpt.py:1.14.6.2
view.py:NONE
Jim Fulton
cvs-admin at zope.org
Tue Nov 18 17:27:07 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv19243/src/zope/app/services
Modified Files:
Tag: adaptergeddon-branch
adapter.py configure.zcml pagefolder.py pagefolder.zcml
registration.py surrogate.py zpt.py
Removed Files:
Tag: adaptergeddon-branch
view.py
Log Message:
Implemented local presentation services.
=== Zope3/src/zope/app/services/adapter.py 1.22 => 1.22.6.1 ===
--- Zope3/src/zope/app/services/adapter.py:1.22 Sun Sep 21 13:31:59 2003
+++ Zope3/src/zope/app/services/adapter.py Tue Nov 18 17:26:35 2003
@@ -17,183 +17,100 @@
"""
__metaclass__ = type
-import sys
from zope.app import zapi
-from zope.interface.adapter import AdapterRegistry
-from persistence import Persistent
-from persistence.dict import PersistentDict
-from zope.interface import implements
-from zope.component.interfaces import IAdapterService
-from zope.component.exceptions import ComponentLookupError
-from zope.app.services.servicenames import Adapters
-from zope.app.interfaces.services.registration import IRegistry
-from zope.app.services.registration import RegistrationStack
-from zope.app.services.registration import SimpleRegistration
-from zope.app.component.nextservice import getNextService
-from zope.app.interfaces.services.service import ISimpleService
-from zope.app.interfaces.services.adapter import IAdapterRegistration
-from zope.app.container.contained import Contained
-
-class PersistentAdapterRegistry(Persistent, AdapterRegistry):
-
- def __init__(self):
- AdapterRegistry.__init__(self, PersistentDict())
-
-
-class AdapterService(Persistent, Contained):
-
- implements(IAdapterService, IRegistry, ISimpleService)
+import sys
+import zope.app.component.interfacefield
+import zope.app.interfaces.services.registration
+import zope.app.interfaces.services.service
+import zope.app.security.permission
+import zope.app.services.registration
+import zope.app.services.surrogate
+import zope.component.interfaces
+import zope.interface
+import zope.schema
+
+
+class LocalAdapterService(
+ zope.app.services.surrogate.LocalSurrogateRegistry,
+ zope.app.services.surrogate.LocalSurrogateBasedService,
+ ):
+
+ zope.interface.implements(
+ zope.component.interfaces.IAdapterService,
+ zope.app.interfaces.services.service.ISimpleService,
+ )
def __init__(self):
- self._byName = PersistentDict()
-
- def queryRegistrationsFor(self, registration, default=None):
- "See IRegistry"
- # XXX Need to add named adapter support
- return self.queryRegistrations(
- registration.forInterface, registration.providedInterface,
- registration.adapterName,
- default)
-
- def queryRegistrations(self,
- forInterface, providedInterface, adapterName,
- default=None):
-
- adapters = self._byName.get(adapterName)
- if adapters is None:
- return default
-
- registry = adapters.getRegistered(forInterface, providedInterface)
- if registry is None:
- return default
-
- return registry
-
- def createRegistrationsFor(self, registration):
- "See IRegistry"
- # XXX Need to add named adapter support
- return self.createRegistrations(
- registration.forInterface, registration.providedInterface,
- registration.adapterName)
-
- def createRegistrations(self, forInterface, providedInterface, name):
-
- adapters = self._byName.get(name)
- if adapters is None:
- adapters = PersistentAdapterRegistry()
- self._byName[name] = adapters
-
- registry = adapters.getRegistered(forInterface, providedInterface)
- if registry is None:
- registry = RegistrationStack(self)
- adapters.register(forInterface, providedInterface, registry)
-
- return registry
-
- def getAdapter(self, object, interface, name=''):
- "See IAdapterService"
- adapter = self.queryAdapter(object, interface, name=name)
- if adapter is None:
- raise ComponentLookupError(object, interface)
- return adapter
-
- def getNamedAdapter(self, object, interface, name):
- "See IAdapterService"
- adapter = self.queryNamedAdapter(object, interface, name)
- if adapter is None:
- raise ComponentLookupError(object, interface)
- return adapter
-
- def queryAdapter(self, object, interface, default=None, name=''):
- """see IAdapterService interface"""
- if name:
- warnings.warn("The name argument to queryAdapter is deprecated",
- DeprecationWarning, 2)
- return queryNamedAdapter(object, interface, name, default, context)
-
- conform = getattr(object, '__conform__', None)
- if conform is not None:
- try:
- adapter = conform(interface)
- except TypeError:
- # We got a TypeError. It might be an error raised by
- # the __conform__ implementation, or *we* may have
- # made the TypeError by calling an unbound method
- # (object is a class). In the later case, we behave
- # as though there is no __conform__ method. We can
- # detect this case by checking whether there is more
- # than one traceback object in the traceback chain:
- if sys.exc_info()[2].tb_next is not None:
- # There is more than one entry in the chain, so
- # reraise the error:
- raise
- # This clever trick is from Phillip Eby
- else:
- if adapter is not None:
- return adapter
-
- if interface.isImplementedBy(object):
- return object
-
- return self.queryNamedAdapter(object, interface, name, default)
-
- def queryNamedAdapter(self, object, interface, name, default=None):
- adapters = self._byName.get(name)
-
- if adapters:
- registry = adapters.getForObject(
- object, interface,
- filter = lambda registry: registry.active(),
- )
-
- if registry is not None:
- adapter = registry.active().getAdapter(object)
- return adapter
-
- adapters = getNextService(self, Adapters)
-
- return adapters.queryNamedAdapter(object, interface, name, default)
-
- # XXX need to add name support
- def getRegisteredMatching(self,
- for_interfaces=None,
- provided_interfaces=None):
-
- adapters = self._byName.get('')
- if adapters is None:
- return ()
-
- return adapters.getRegisteredMatching(for_interfaces,
- provided_interfaces)
+ zope.app.services.surrogate.LocalSurrogateRegistry.__init__(
+ self, zapi.getService(None, zapi.servicenames.Adapters)
+ )
+
+
+
+class IAdapterRegistration(
+ zope.app.interfaces.services.registration.IRegistration):
+
+ required = zope.app.component.interfacefield.InterfaceField(
+ title = u"For interface",
+ description = u"The interface of the objects being adapted",
+ readonly = True,
+ basetype = None,
+ )
+
+ provided = zope.app.component.interfacefield.InterfaceField(
+ title = u"Provided interface",
+ description = u"The interface provided",
+ readonly = True,
+ required = True,
+ )
+
+ name = zope.schema.TextLine(
+ title=u"Name",
+ readonly=True,
+ required=False,
+ )
+
+ factoryName = zope.schema.BytesLine(
+ title=u"The dotted name of a factory for creating the adapter",
+ readonly = True,
+ required = True,
+ )
+
+ permission = zope.app.security.permission.PermissionField(
+ title=u"The permission required for use",
+ readonly=False,
+ required=False,
+ )
+
+ factories = zope.interface.Attribute(
+ "A sequence of factories to be called to construct the component"
+ )
+
+class AdapterRegistration(zope.app.services.registration.SimpleRegistration):
-class AdapterRegistration(SimpleRegistration):
+ zope.interface.implements(IAdapterRegistration)
- implements(IAdapterRegistration)
+ serviceType = zapi.servicenames.Adapters
- serviceType = Adapters
+ with = () # XXX Don't support multi-adapters yet
- # XXX These should be positional arguments, except that forInterface
+ # XXX These should be positional arguments, except that required
# isn't passed in if it is omitted. To fix this, we need a
# required=False,explicitly_unrequired=True in the schema field
# so None will get passed in.
- def __init__(self, forInterface=None, providedInterface=None,
- factoryName=None, adapterName=u'',
- # XXX The permission isn't plumbed. We're going to
- # redo all of this anyway.
- permission=None,
- ):
- if None in (providedInterface, factoryName):
- raise TypeError(
- "Must provide 'providedInterface' and 'factoryName'")
- self.forInterface = forInterface
- self.providedInterface = providedInterface
- self.adapterName = adapterName
+ def __init__(self, provided, factoryName,
+ name='', required=None, permission=None):
+ self.required = required
+ self.provided = provided
+ self.name = name
self.factoryName = factoryName
+ self.permission = permission
- def getAdapter(self, object):
+ def factories(self):
folder = self.__parent__.__parent__
factory = folder.resolve(self.factoryName)
- return factory(object)
+ return factory,
+ factories = property(factories)
# XXX Pickle backward compatability
AdapterConfiguration = AdapterRegistration
=== Zope3/src/zope/app/services/configure.zcml 1.57.6.1 => 1.57.6.2 ===
--- Zope3/src/zope/app/services/configure.zcml:1.57.6.1 Sun Nov 9 11:08:26 2003
+++ Zope3/src/zope/app/services/configure.zcml Tue Nov 18 17:26:35 2003
@@ -31,14 +31,16 @@
/>
</content>
+<adapter
+ for="zope.app.interfaces.services.registration.IRegisterable"
+ provides="zope.app.interfaces.services.registration.IRegistered"
+ factory="zope.app.services.registration.Registered"
+ />
<!-- Adapter Service -->
-<content class="zope.app.services.adapter.AdapterService">
- <factory
- id="zope.app.services.AdapterService"
- permission="zope.ManageServices"
- />
+<content class="zope.app.services.adapter.LocalAdapterService">
+ <factory permission="zope.ManageServices" />
<require
permission="zope.ManageServices"
interface="zope.app.interfaces.services.registration.IRegistry"
@@ -46,10 +48,10 @@
/>
</content>
-<content class="zope.app.services.adapter.AdapterRegistration">
+<content class=".adapter.AdapterRegistration">
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.adapter.IAdapterRegistration"
+ interface=".adapter.IAdapterRegistration"
set_schema="zope.app.interfaces.services.registration.IRegistration"
/>
<require
@@ -58,102 +60,9 @@
/>
</content>
-<!-- View Service
-
-<content class="zope.app.services.presentat.ViewService">
- <factory
- id="zope.app.services.ViewService"
- permission="zope.ManageServices"
- />
- <require
- permission="zope.ManageServices"
- interface="zope.app.interfaces.services.registration.IRegistry"
- attributes="getRegisteredMatching"
- />
-</content>
-
-<content class="zope.app.services.view.ViewRegistration">
- <require
- permission="zope.ManageServices"
- interface="zope.app.interfaces.services.view.IViewRegistration"
- set_schema="zope.app.interfaces.services.registration.IRegistration"
- />
- <require
- permission="zope.ManageServices"
- interface="zope.app.interfaces.container.IRemoveNotifiable"
- />
-</content>
-
-<content class="zope.app.services.view.PageRegistration">
- <require
- permission="zope.ManageServices"
- interface="zope.app.interfaces.services.view.IPageRegistration"
- set_schema="zope.app.interfaces.services.view.IPageRegistration"
- />
- <require
- permission="zope.ManageServices"
- interface="zope.app.interfaces.container.IRemoveNotifiable"
- />
-</content>
-
-<adapter
- for="zope.component.interfaces.IGlobalViewService"
- provides="zope.app.interfaces.services.interface.IInterfaceBasedRegistry"
- factory=".view.RegistrationAdapter"
- />
-
-
--->
-
<!-- Menu Service -->
<include file="menu.zcml"/>
-
-<!-- Page Templates
-
-<content class="zope.app.services.zpt.ZPTTemplate">
- <factory
- id="zope.app.services.zpt.template"
- permission="zope.ManageServices"
- title="ZPT Template"
- description="Page Template"
- />
- <require
- permission="zope.View"
- attributes="__call__"
- />
- <require
- permission="zope.ManageServices"
- interface="zope.app.interfaces.services.view.IZPTTemplate"
- set_schema="zope.app.interfaces.services.view.IZPTTemplate"
- />
- <implements
- interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
- />
-</content>
-
-<adapter
- for="zope.app.interfaces.services.view.IZPTTemplate"
- provides="zope.app.interfaces.file.IReadFile"
- factory=".zpt.ReadFile"
- permission="zope.ManageServices"
- />
-
-<adapter
- for="zope.app.interfaces.services.view.IZPTTemplate"
- provides="zope.app.interfaces.file.IWriteFile"
- factory=".zpt.WriteFile"
- permission="zope.ManageServices"
- />
-
-<adapter
- for="zope.app.interfaces.services.registration.IRegisterable"
- provides="zope.app.interfaces.services.registration.IRegistered"
- factory="zope.app.services.registration.Registered"
- />
-
- -->
-
<!-- Role Templates -->
<content class="zope.app.services.role.RoleService">
@@ -314,6 +223,12 @@
/>
</content>
+<!-- Presentation components -->
+ <include file="presentation.zcml" />
+
+<!-- Page templates -->
+ <include file="zpt.zcml" />
+
<!-- Page Folder -->
<include file="pagefolder.zcml" />
@@ -466,11 +381,6 @@
<fssync:adapter
class=".service.ServiceManager"
factory=".service.ServiceManagerAdapter"
- />
-
-<fssync:adapter
- class=".zpt.ZPTTemplate"
- factory=".zpt.ZPTPageAdapter"
/>
<fssync:adapter
=== Zope3/src/zope/app/services/pagefolder.py 1.14.6.1 => 1.14.6.2 ===
--- Zope3/src/zope/app/services/pagefolder.py:1.14.6.1 Sun Nov 9 11:08:26 2003
+++ Zope3/src/zope/app/services/pagefolder.py Tue Nov 18 17:26:35 2003
@@ -21,28 +21,79 @@
__metaclass__ = type
from zope.app.container.btree import BTreeContainer
-from zope.app.interfaces.services.presentation import IZPTTemplate
+from zope.app.services.zpt import IZPTTemplate
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.app.traversing import getPath
from zope.app.interfaces.services.registration import ActiveStatus
from zope.app.services.registration import RegistrationManagerContainer
from zope.proxy import removeAllProxies
-from zope.app.services.view import PageRegistration
-from zope.app.interfaces.services.pagefolder import IPageFolder
+from zope.app.services.presentation import PageRegistration
from zope.app.interfaces.services.registration import IRegistrationManager
-from zope.app.interfaces.file import IDirectoryFactory
from zope.app.fssync.classes import ObjectEntryAdapter, AttrMapping
-from zope.app.interfaces.fssync import IObjectDirectory
-from zope.interface import implements
from zope.app.interfaces.services.registration import ActiveStatus
from zope.app.interfaces.services.registration import RegisteredStatus
from zope.app.interfaces.services.registration import UnregisteredStatus
+import zope.app.component.interfacefield
+import zope.app.interfaces.container
+import zope.app.interfaces.file
+import zope.app.interfaces.fssync
+import zope.app.interfaces.services.registration
+import zope.app.security.permission
+import zope.interface
+import zope.schema
+
+class IPageFolderInfo(zope.interface.Interface):
+ """Default registration information for page folders
+
+ This information is used to configure the pages in the folder.
+ """
+
+ required = zope.app.component.interfacefield.InterfaceField(
+ title = u"For interface",
+ description = u"The interface of the objects being viewed",
+ required = True,
+ )
+
+ factoryName = zope.schema.BytesLine(
+ title=u"The dotted name of a factory for creating the view",
+ required = False,
+ )
+
+ layer = zope.schema.BytesLine(
+ title = u"Layer",
+ description = u"The skin layer the view is registered for",
+ required = False,
+ min_length = 1,
+ default = "default",
+ )
+
+ permission = zope.app.security.permission.PermissionField(
+ title=u"Permission",
+ description=u"The permission required to use the view",
+ required = True,
+ )
+
+ apply = zope.schema.Bool(
+ title=u"Apply changes to existing pages",
+ required = True,
+ )
+
+class IPageFolder(
+ IPageFolderInfo,
+ zope.app.interfaces.container.IContainer,
+ zope.app.interfaces.services.registration.IRegistrationManagerContainer,
+ ):
+
+ def applyDefaults(self):
+ """Apply the default configuration to the already-registered pages.
+ """
+
class PageFolder(RegistrationManagerContainer, BTreeContainer):
- implements(IPageFolder)
+ zope.interface.implements(IPageFolder)
- presentationType = IBrowserRequest
+ requestType = IBrowserRequest
layer = "default"
description = ''
title = ''
@@ -70,10 +121,10 @@
template = self[name]
template = getPath(template)
registration = PageRegistration(
- forInterface=self.forInterface,
- viewName=name,
+ required=self.required,
+ name=name,
permission=self.permission,
- class_=self.factoryName,
+ factoryName=self.factoryName,
template=template,
layer=self.layer,
)
@@ -95,11 +146,11 @@
registration.status = RegisteredStatus
registration.status = UnregisteredStatus
- # Cheat and set forInterface and layer even though they're
+ # Cheat and set required and layer even though they're
# read-only. This is ok since the registration is now not
# registered.
- registration.forInterface = removeAllProxies(self.forInterface)
+ registration.required = removeAllProxies(self.required)
registration.factoryName = self.factoryName
registration.layer = self.layer
registration.permission = self.permission
@@ -111,7 +162,7 @@
_attrNames = (
'factoryName',
- 'forInterface',
+ 'required',
'layer',
'permission',
)
@@ -119,7 +170,7 @@
class PageFolderAdapter(ObjectEntryAdapter):
"""ObjectFile adapter for PageFolder objects."""
- implements(IObjectDirectory)
+ zope.interface.implements(zope.app.interfaces.fssync.IObjectDirectory)
def contents(self):
return self.context.items()
@@ -130,7 +181,7 @@
class PageFolderFactory:
- implements(IDirectoryFactory)
+ zope.interface.implements(zope.app.interfaces.file.IDirectoryFactory)
def __init__(self, context):
self.context = context
=== Zope3/src/zope/app/services/pagefolder.zcml 1.3 => 1.3.6.1 ===
--- Zope3/src/zope/app/services/pagefolder.zcml:1.3 Sun Sep 21 13:32:55 2003
+++ Zope3/src/zope/app/services/pagefolder.zcml Tue Nov 18 17:26:35 2003
@@ -18,8 +18,8 @@
<require
permission="zope.ManageServices"
interface="zope.app.interfaces.container.IWriteContainer
- zope.app.interfaces.services.pagefolder.IPageFolderInfo"
- set_schema="zope.app.interfaces.services.pagefolder.IPageFolderInfo"
+ zope.app.services.pagefolder.IPageFolderInfo"
+ set_schema="zope.app.services.pagefolder.IPageFolderInfo"
attributes="getRegistrationManager applyDefaults"
/>
<implements
@@ -27,7 +27,7 @@
</content>
<adapter
- for="zope.app.interfaces.services.pagefolder.IPageFolder"
+ for="zope.app.services.pagefolder.IPageFolder"
provides="zope.app.interfaces.file.IFileFactory"
factory=".zpt.ZPTFactory"
permission="zope.ManageServices"
=== Zope3/src/zope/app/services/registration.py 1.16.6.1 => 1.16.6.2 ===
--- Zope3/src/zope/app/services/registration.py:1.16.6.1 Tue Nov 11 10:52:32 2003
+++ Zope3/src/zope/app/services/registration.py Tue Nov 18 17:26:35 2003
@@ -152,9 +152,12 @@
data = self._data
if data:
if data[0] == cid:
+ data = data[1:]
+ self._data = data
+
# Tell it that it is no longer active
registration.deactivated()
- data = data[1:]
+
if data and data[0] is not None:
# Activate the newly active component
sm = zapi.getServiceManager(self)
@@ -168,8 +171,7 @@
if data and data[-1] is None:
data = data[:-1]
- # Write data back
- self._data = data
+ self._data = data
def registered(self, registration):
cid = self._id(registration)
@@ -186,16 +188,10 @@
return # already in the state we want
if cid is None or cid in data:
-
- if data[0] == cid:
+ old = data[0]
+ if old == cid:
return # already active
- if data[0] is not None:
- # Deactivate the currently active component
- sm = zapi.getServiceManager(self)
- old = zapi.traverse(sm, data[0])
- old.deactivated()
-
# Insert it in front, removing it from back
data = (cid, ) + tuple([item for item in data if item != cid])
@@ -206,6 +202,12 @@
# Write data back
self._data = data
+ if old is not None:
+ # Deactivated the currently active component
+ sm = zapi.getServiceManager(self)
+ old = zapi.traverse(sm, old)
+ old.deactivated()
+
if registration is not None:
# Tell it that it is now active
registration.activated()
@@ -227,9 +229,6 @@
if data[0] != cid:
return # already inactive
- # Tell it that it is no longer active
- registration.deactivated()
-
if None not in data:
# Append None
data += (None,)
@@ -237,14 +236,17 @@
# Move it to the end
data = data[1:] + data[:1]
+ # Write data back
+ self._data = data
+
+ # Tell it that it is no longer active
+ registration.deactivated()
+
if data[0] is not None:
# Activate the newly active component
sm = zapi.getServiceManager(self)
new = zapi.traverse(sm, data[0])
new.activated()
-
- # Write data back
- self._data = data
def active(self):
if self._data:
=== Zope3/src/zope/app/services/surrogate.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/services/surrogate.py:1.1.2.1 Wed Nov 12 15:08:12 2003
+++ Zope3/src/zope/app/services/surrogate.py Tue Nov 18 17:26:35 2003
@@ -19,8 +19,13 @@
from persistence import Persistent
from persistence.dict import PersistentDict
from zope.interface.surrogate import Surrogate, SurrogateRegistry
-from zope.interface.surrogate import adapterImplied
+from zope.interface.surrogate import adapterImplied, Default
from zope.app.services.registration import NotifyingRegistrationStack
+import zope.app.component.nextservice
+import zope.app.container.contained
+import zope.app.interfaces.services.service
+import zope.app.interfaces.services.registration
+from zope.app import zapi
class LocalSurrogate(Surrogate):
"""Local surrogates
@@ -51,6 +56,10 @@
"""Local/persistent surrogate registry
"""
+ zope.interface.implements(
+ zope.app.interfaces.services.registration.IRegistry,
+ )
+
_surrogateClass = LocalSurrogate
next = None
subs = ()
@@ -62,7 +71,9 @@
SurrogateRegistry.__init__(self)
self.setNext(next)
- def setNext(self, next):
+ def setNext(self, next, base=None):
+ if base is not None:
+ self.base = base
if self.next is not None:
self.next.removeSub(self)
if next is not None:
@@ -77,14 +88,14 @@
self.subs = tuple([s for s in self.subs if s is not sub])
def __getstate__(self):
- return 'state1', (self.base, self.next, self.subs, self.adapters,
- self.stacks)
+ state = Persistent.__getstate__(self).copy()
+ del state['_surrogates']
+ del state['_default']
+ del state['_remove']
+ return state
- def state1(self, data):
- self.base, self.next, self.subs, self.adapters, self.stacks = data
-
def __setstate__(self, state):
- getattr(self, state[0])(state[1])
+ Persistent.__setstate__(self, state)
SurrogateRegistry.__init__(self)
def baseFor(self, spec):
@@ -118,12 +129,14 @@
def adaptersChanged(self, *args):
+ adapters = {}
if self.next is not None:
- adapters = self.next.adapters.copy()
- else:
- adapters = {}
-
+ for required, radapters in self.next.adapters.iteritems():
+ adapters[required] = radapters.copy()
+
for required, stacks in self.stacks.iteritems():
+ if required is None:
+ required = Default
radapters = adapters.get(required)
if not radapters:
radapters = {}
@@ -132,7 +145,7 @@
for key, stack in stacks.iteritems():
registration = stack.active()
if registration is not None:
- radapters[key] = [registration]
+ radapters[key] = registration.factories
if adapters != self.adapters:
@@ -143,3 +156,51 @@
sub.adaptersChanged()
notifyActivated = notifyDeactivated = adaptersChanged
+
+class LocalSurrogateBasedService(
+ zope.app.container.contained.Contained,
+ Persistent,
+ ):
+ """A service that uses local surrogate registries
+
+ A local surrogate-based service needs to maintain connections
+ between it's surrogate registries and those of containing ans
+ sub-services.
+
+ The service must implement a setNext method that will be called
+ with the next local service, which may be None, and the global
+ service. This method will be called when a service is bound.
+
+ """
+
+ zope.interface.implements(
+ zope.app.interfaces.services.service.IBindingAware,
+ )
+
+ def __updateNext(self, servicename):
+ next = zope.app.component.nextservice.getNextService(self, servicename)
+ global_ = zapi.getService(None, servicename)
+ if next == global_:
+ next = None
+ self.setNext(next, global_)
+
+ def bound(self, servicename):
+ self.__updateNext(servicename)
+
+ # Now, we need to notify any sub-site services. This is
+ # a bit complicated because our immediate subsites might not have
+ # the same service. Sigh
+ sm = zapi.getServiceManager(self)
+ self.__notifySubs(sm.subSites, servicename)
+
+ def unbound(self, servicename):
+ sm = zapi.getServiceManager(self)
+ self.__notifySubs(sm.subSites, servicename)
+
+ def __notifySubs(self, subs, servicename):
+ for sub in subs:
+ s = sub.queryLocalService(servicename)
+ if s is not None:
+ s.__updateNext(servicename)
+ else:
+ self.__notifySubs(sub.subSites, servicename)
=== Zope3/src/zope/app/services/zpt.py 1.14.6.1 => 1.14.6.2 ===
--- Zope3/src/zope/app/services/zpt.py:1.14.6.1 Sun Nov 9 11:08:26 2003
+++ Zope3/src/zope/app/services/zpt.py Tue Nov 18 17:26:35 2003
@@ -15,24 +15,57 @@
$Id$
"""
+from zope.security.proxy import ProxyFactory
+import persistence
import re
+import zope.app.container.contained
+import zope.app.fssync.classes
+import zope.app.interfaces.file
+import zope.app.interfaces.fssync
+import zope.app.interfaces.index.text
+import zope.app.pagetemplate.engine
+import zope.interface
+import zope.pagetemplate.pagetemplate
+import zope.schema
+
+class IZPTTemplate(zope.interface.Interface):
+ """ZPT Templates for use in views
+ """
+
+ contentType = zope.schema.BytesLine(
+ title=u'Content type of generated output',
+ required=True,
+ default='text/html'
+ )
-from persistence import Persistent
+ source = zope.schema.Text(
+ title=u"Source",
+ description=u"""The source of the page template.""",
+ required=True)
-from zope.interface import implements
-from zope.security.proxy import ProxyFactory
-from zope.pagetemplate.pagetemplate import PageTemplate
-from zope.app.pagetemplate.engine import AppPT
-from zope.app.interfaces.services.presentation import IZPTTemplate
-from zope.app.interfaces.index.text import ISearchableText
-from zope.app.interfaces.file import IReadFile, IWriteFile, IFileFactory
-from zope.app.fssync.classes import ObjectEntryAdapter, AttrMapping
-from zope.app.interfaces.fssync import IObjectFile
-from zope.app.container.contained import Contained
+ expand = zope.schema.Bool(
+ title=u"Expand macros",
+ )
+
+ def render(context, request, *args, **kw):
+ """Render the page template.
-class ZPTTemplate(AppPT, PageTemplate, Persistent, Contained):
+ The context argument is bound to the top-level 'context'
+ variable. The request argument is bound to the top-level
+ 'request' variable. The positional arguments are bound to the
+ 'args' variable and the keyword arguments are bound to the
+ 'options' variable.
+
+ """
+
+class ZPTTemplate(
+ zope.app.pagetemplate.engine.AppPT,
+ zope.pagetemplate.pagetemplate.PageTemplate,
+ persistence.Persistent,
+ zope.app.container.contained.Contained,
+ ):
- implements(IZPTTemplate)
+ zope.interface.implements(IZPTTemplate)
contentType = 'text/html'
expand = False
@@ -75,7 +108,7 @@
tag = re.compile(r"<[^>]+>")
class SearchableText:
- implements(ISearchableText)
+ zope.interface.implements(zope.app.interfaces.index.text.ISearchableText)
__used_for__ = IZPTTemplate
def __init__(self, page):
@@ -99,7 +132,7 @@
class ReadFile:
- implements(IReadFile)
+ zope.interface.implements(zope.app.interfaces.file.IReadFile)
def __init__(self, context):
self.context = context
@@ -113,7 +146,7 @@
class WriteFile:
- implements(IWriteFile)
+ zope.interface.implements(zope.app.interfaces.file.IWriteFile)
def __init__(self, context):
self.context = context
@@ -124,7 +157,7 @@
class ZPTFactory:
- implements(IFileFactory)
+ zope.interface.implements(zope.app.interfaces.file.IFileFactory)
def __init__(self, context):
self.context = context
@@ -135,10 +168,10 @@
return r
-class ZPTPageAdapter(ObjectEntryAdapter):
+class ZPTPageAdapter(zope.app.fssync.classes.ObjectEntryAdapter):
"""ObjectFile adapter for ZPTTemplate objects."""
- implements(IObjectFile)
+ zope.interface.implements(zope.app.interfaces.fssync.IObjectFile)
def getBody(self):
return self.context.source
@@ -150,4 +183,5 @@
self.context.source = unicode(data)
def extra(self):
- return AttrMapping(self.context, ('contentType', 'expand'))
+ return zope.app.fssync.classes.AttrMapping(
+ self.context, ('contentType', 'expand'))
=== Removed File Zope3/src/zope/app/services/view.py ===
More information about the Zope3-Checkins
mailing list