[Zope-Checkins] SVN: Products.Five/branches/zope33-port/ Merge
philikon-local-components branch into this one. This retires
Philipp von Weitershausen
philikon at philikon.de
Thu Apr 27 16:37:51 EDT 2006
Log message for revision 67668:
Merge philikon-local-components branch into this one. This retires
philikon-local-components branch.
Changed:
U Products.Five/branches/zope33-port/__init__.py
U Products.Five/branches/zope33-port/browser/TrustedExpression.py
U Products.Five/branches/zope33-port/browser/__init__.py
U Products.Five/branches/zope33-port/browser/absoluteurl.py
U Products.Five/branches/zope33-port/browser/adding.py
U Products.Five/branches/zope33-port/browser/configure.zcml
U Products.Five/branches/zope33-port/browser/metaconfigure.py
U Products.Five/branches/zope33-port/browser/pagetemplatefile.py
U Products.Five/branches/zope33-port/browser/resource.py
U Products.Five/branches/zope33-port/browser/tests/pages.txt
A Products.Five/branches/zope33-port/browser/tests/skin.py
U Products.Five/branches/zope33-port/browser/tests/skin.zcml
U Products.Five/branches/zope33-port/browser/tests/test_absoluteurl.py
U Products.Five/branches/zope33-port/browser/tests/test_menu.py
A Products.Five/branches/zope33-port/component/
U Products.Five/branches/zope33-port/configure.zcml
U Products.Five/branches/zope33-port/event.zcml
U Products.Five/branches/zope33-port/fiveconfigure.py
U Products.Five/branches/zope33-port/fivedirectives.py
U Products.Five/branches/zope33-port/form/__init__.py
U Products.Five/branches/zope33-port/form/metaconfigure.py
U Products.Five/branches/zope33-port/form/tests/test_forms.py
U Products.Five/branches/zope33-port/formlib/formbase.py
U Products.Five/branches/zope33-port/i18n.py
U Products.Five/branches/zope33-port/meta.zcml
U Products.Five/branches/zope33-port/metaconfigure.py
U Products.Five/branches/zope33-port/security.py
U Products.Five/branches/zope33-port/site/browser.py
U Products.Five/branches/zope33-port/site/configure.zcml
U Products.Five/branches/zope33-port/site/interfaces.py
U Products.Five/branches/zope33-port/site/localsite.py
U Products.Five/branches/zope33-port/site/metaconfigure.py
U Products.Five/branches/zope33-port/site/tests/dummy.py
U Products.Five/branches/zope33-port/site/tests/sitemanager.txt
U Products.Five/branches/zope33-port/site/tests/test_localsite.py
U Products.Five/branches/zope33-port/site/tests/test_utility.py
U Products.Five/branches/zope33-port/site/utility.py
U Products.Five/branches/zope33-port/sizeconfigure.py
U Products.Five/branches/zope33-port/skin/standardmacros.py
U Products.Five/branches/zope33-port/tests/directives.zcml
U Products.Five/branches/zope33-port/tests/event.txt
U Products.Five/branches/zope33-port/tests/test_event.py
U Products.Five/branches/zope33-port/tests/test_i18n.py
U Products.Five/branches/zope33-port/tests/test_security.py
U Products.Five/branches/zope33-port/tests/test_size.py
U Products.Five/branches/zope33-port/traversable.py
A Products.Five/branches/zope33-port/traversing.zcml
U Products.Five/branches/zope33-port/utilities/browser/tests/test_marker.py
U Products.Five/branches/zope33-port/utilities/marker.py
U Products.Five/branches/zope33-port/viewable.py
-=-
Modified: Products.Five/branches/zope33-port/__init__.py
===================================================================
--- Products.Five/branches/zope33-port/__init__.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/__init__.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -18,12 +18,23 @@
import Acquisition
from Globals import INSTANCE_HOME
-import zcml
+from Products.Five import zcml
# public API provided by Five
# usage: from Products.Five import <something>
-from browser import BrowserView
-from skin.standardmacros import StandardMacros
+from Products.Five.browser import BrowserView
+from Products.Five.skin.standardmacros import StandardMacros
+# load the site's ZCML tree (usually site.zcml) upon product
+# initialization
def initialize(context):
zcml.load_site()
+
+# some convenience methods/decorators
+
+def fivemethod(func):
+ func.__five_method__ = True
+ return func
+
+def isFiveMethod(m):
+ return hasattr(m, '__five_method__')
Modified: Products.Five/branches/zope33-port/browser/TrustedExpression.py
===================================================================
--- Products.Five/branches/zope33-port/browser/TrustedExpression.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/TrustedExpression.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -15,10 +15,7 @@
$Id$
"""
-from sys import modules
-
from Products.PageTemplates.PythonExpr import PythonExpr
-
from Products.PageTemplates.Expressions import \
SubPathExpr, PathExpr, \
StringExpr, \
Modified: Products.Five/branches/zope33-port/browser/__init__.py
===================================================================
--- Products.Five/branches/zope33-port/browser/__init__.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/__init__.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -16,9 +16,9 @@
$Id$
"""
import Acquisition
-import zope.app.publisher.browser
+import zope.publisher.browser
-class BrowserView(Acquisition.Explicit, zope.app.publisher.browser.BrowserView):
+class BrowserView(Acquisition.Explicit, zope.publisher.browser.BrowserView):
"""Five browser view
Mixes in explicit acquisition so that security can be acquired for
Modified: Products.Five/branches/zope33-port/browser/absoluteurl.py
===================================================================
--- Products.Five/branches/zope33-port/browser/absoluteurl.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/absoluteurl.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -19,15 +19,15 @@
from OFS.interfaces import ITraversable
from zope.interface import implements
-from zope.app import zapi
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
+from zope.component import getMultiAdapter
+from zope.traversing.browser.interfaces import IAbsoluteURL
from Products.Five.browser import BrowserView
class AbsoluteURL(BrowserView):
"""An adapter for Zope3-style absolute_url using Zope2 methods
- (original: zope.app.traversing.browser.absoluteurl)
+ (original: zope.traversing.browser.absoluteurl)
"""
implements(IAbsoluteURL)
@@ -52,7 +52,7 @@
return (
{'name': name, 'url': context.absolute_url()},)
- view = zapi.getMultiAdapter((container, request), IAbsoluteURL)
+ view = getMultiAdapter((container, request), IAbsoluteURL)
base = tuple(view.breadcrumbs())
base += (
{'name': name, 'url': ("%s/%s" % (base[-1]['url'], name))},)
@@ -72,7 +72,7 @@
This one is just used to stop breadcrumbs from crumbing up
to the Zope root.
- (original: zope.app.traversing.browser.absoluteurl)
+ (original: zope.traversing.browser.absoluteurl)
"""
def breadcrumbs(self):
Modified: Products.Five/branches/zope33-port/browser/adding.py
===================================================================
--- Products.Five/branches/zope33-port/browser/adding.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/adding.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -19,30 +19,28 @@
__docformat__ = 'restructuredtext'
from warnings import warn
+
+import zope.component
from zope.interface import implements
from zope.publisher.interfaces import IPublishTraverse
from zope.component.interfaces import IFactory
+from zope.event import notify
+from zope.exceptions import UserError
+from zope.lifecycleevent import ObjectCreatedEvent
-from zope.app.exception.interfaces import UserError
from zope.app.container.interfaces import IAdding, INameChooser
from zope.app.container.interfaces import IContainerNamesContainer
from zope.app.container.constraints import checkFactory, checkObject
-
from zope.app.publisher.browser.menu import getMenu
-from zope.app import zapi
-from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.event import notify
-
+from Acquisition import Implicit
from zExceptions import BadRequest
+from OFS.SimpleItem import SimpleItem
from Products.Five import BrowserView
from Products.Five.traversable import Traversable
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
-from Acquisition import Implicit
-from OFS.SimpleItem import SimpleItem
-
class BasicAdding(Implicit, BrowserView):
implements(IAdding, IPublishTraverse)
@@ -86,8 +84,8 @@
# XXX this is definitely not right for all or even most uses
# of Five, but can be overridden by an AddView subclass, using
# the class attribute of a zcml:addform directive
- return str(zapi.getMultiAdapter((self.context, self.request),
- name=u"absolute_url")) + '/manage_main'
+ return str(zope.component.getMultiAdapter(
+ (self.context, self.request), name=u"absolute_url")) + '/manage_main'
# set in BrowserView.__init__
request = None
@@ -106,18 +104,18 @@
if view_name.startswith('@@'):
view_name = view_name[2:]
- return zapi.getMultiAdapter((self, request), name=view_name)
+ return zope.component.getMultiAdapter((self, request), name=view_name)
if name.startswith('@@'):
view_name = name[2:]
else:
view_name = name
- view = zapi.queryView(self, view_name, request)
+ view = zope.component.queryMultiAdapter((self, request), name=view_name)
if view is not None:
return view
- factory = zapi.queryUtility(IFactory, name)
+ factory = zope.component.queryUtility(IFactory, name)
if factory is None:
return super(BasicAdding, self).publishTraverse(request, name)
@@ -135,9 +133,10 @@
else:
view_name = type_name
- if zapi.queryView(self, view_name, self.request) is not None:
+ if (zope.component.queryMultiAdapter((self, self.request), name=view_name)
+ is not None):
url = "%s/%s=%s" % (
- zapi.getMultiAdapter((self, self.request), name=u"absolute_url"),
+ zope.component.getMultiAdapter((self, self.request), name=u"absolute_url"),
type_name, id)
self.request.response.redirect(url)
return
@@ -145,7 +144,7 @@
if not self.contentName:
self.contentName = id
- factory = zapi.getUtility(IFactory, type_name)
+ factory = zope.component.getUtility(IFactory, type_name)
content = factory()
notify(ObjectCreatedEvent(content))
@@ -180,7 +179,7 @@
if extra:
factory = extra.get('factory')
if factory:
- factory = zapi.getUtility(IFactory, factory)
+ factory = zope.component.getUtility(IFactory, factory)
if not checkFactory(container, None, factory):
continue
elif item['extra']['factory'] != item['action']:
Modified: Products.Five/branches/zope33-port/browser/configure.zcml
===================================================================
--- Products.Five/branches/zope33-port/browser/configure.zcml 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/configure.zcml 2006-04-27 20:37:46 UTC (rev 67668)
@@ -4,28 +4,19 @@
<browser:defaultView name="index.html" />
<interface
- interface="zope.publisher.interfaces.browser.ILayer"
+ interface="zope.publisher.interfaces.browser.IBrowserSkinType"
/>
<interface
- interface="zope.publisher.interfaces.browser.ISkin"
- />
-
- <interface
interface="zope.app.publisher.interfaces.browser.IMenuItemType"
/>
- <browser:layer
- name="default"
- interface="zope.publisher.interfaces.browser.IDefaultBrowserLayer"
- />
-
<browser:page
for="*"
name="absolute_url"
class=".absoluteurl.AbsoluteURL"
permission="zope.Public"
- allowed_interface="zope.app.traversing.browser.interfaces.IAbsoluteURL"
+ allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
/>
<view
@@ -33,23 +24,23 @@
factory=".absoluteurl.AbsoluteURL"
type="zope.publisher.interfaces.http.IHTTPRequest"
permission="zope.Public"
- provides="zope.app.traversing.browser.interfaces.IAbsoluteURL"
+ provides="zope.traversing.browser.interfaces.IAbsoluteURL"
/>
<browser:page
- for="zope.app.traversing.interfaces.IContainmentRoot"
+ for="zope.traversing.interfaces.IContainmentRoot"
name="absolute_url"
class=".absoluteurl.SiteAbsoluteURL"
permission="zope.Public"
- allowed_interface="zope.app.traversing.browser.interfaces.IAbsoluteURL"
+ allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
/>
<view
- for="zope.app.traversing.interfaces.IContainmentRoot"
+ for="zope.traversing.interfaces.IContainmentRoot"
factory=".absoluteurl.SiteAbsoluteURL"
type="zope.publisher.interfaces.http.IHTTPRequest"
permission="zope.Public"
- provides="zope.app.traversing.browser.interfaces.IAbsoluteURL"
+ provides="zope.traversing.browser.interfaces.IAbsoluteURL"
/>
<browser:view
Modified: Products.Five/branches/zope33-port/browser/metaconfigure.py
===================================================================
--- Products.Five/branches/zope33-port/browser/metaconfigure.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/metaconfigure.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -22,6 +22,8 @@
from zope import component
from zope.interface import Interface
+from zope.component.zcml import handler
+from zope.component.interface import provideInterface
from zope.configuration.exceptions import ConfigurationError
from zope.publisher.interfaces.browser import IBrowserRequest, \
IDefaultBrowserLayer
@@ -30,11 +32,10 @@
from zope.app.publisher.browser.viewmeta import view as zope_app_view
from zope.app.publisher.browser.viewmeta import providesCallable, \
_handle_menu, _handle_for
-from zope.app.component.metaconfigure import handler
-from zope.app.component.interface import provideInterface
from Products.Five.browser import BrowserView
-from Products.Five.browser.resource import FileResourceFactory, ImageResourceFactory
+from Products.Five.browser.resource import FileResourceFactory
+from Products.Five.browser.resource import ImageResourceFactory
from Products.Five.browser.resource import PageTemplateResourceFactory
from Products.Five.browser.resource import DirectoryResourceFactory
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
@@ -125,8 +126,8 @@
_context.action(
discriminator = ('view', for_, name, IBrowserRequest, layer),
callable = handler,
- args = ('provideAdapter',
- (for_, layer), Interface, name, new_class, _context.info),
+ args = ('registerAdapter',
+ new_class, (for_, layer), Interface, name, _context.info),
)
_context.action(
discriminator = ('five:protectClass', new_class),
@@ -193,8 +194,8 @@
if name in pages:
return getattr(self, pages[name])
- view = component.queryMultiAdapter((self, request), name = name,
- default = None)
+ view = component.queryMultiAdapter((self, request), name=name,
+ default=None)
if view is not None:
return view.__of__(self)
@@ -207,8 +208,8 @@
if name in pages:
return getattr(self, pages[name])
- view = component.queryMultiAdapter((self, request), name = name,
- default = None)
+ view = component.queryMultiAdapter((self, request), name=name,
+ default=None)
if view is not None:
return view.__of__(self)
@@ -253,8 +254,8 @@
discriminator = ('view', for_, name, IBrowserRequest, layer,
self.provides),
callable = handler,
- args = ('provideAdapter',
- (for_, layer), self.provides, name, newclass,
+ args = ('registerAdapter',
+ newclass, (for_, layer), self.provides, name,
_context.info),
)
@@ -293,8 +294,8 @@
_context.action(
discriminator = ('resource', name, IBrowserRequest, layer),
callable = handler,
- args = ('provideAdapter',
- (layer,), Interface, name, factory, _context.info),
+ args = ('registerAdapter',
+ factory, (layer,), Interface, name, _context.info),
)
_context.action(
discriminator = ('five:protectClass', new_class),
@@ -360,8 +361,8 @@
_context.action(
discriminator = ('resource', name, IBrowserRequest, layer),
callable = handler,
- args = ('provideAdapter',
- (layer,), Interface, name, factory, _context.info),
+ args = ('registerAdapter',
+ factory, (layer,), Interface, name, _context.info),
)
for new_class in new_classes:
_context.action(
Modified: Products.Five/branches/zope33-port/browser/pagetemplatefile.py
===================================================================
--- Products.Five/branches/zope33-port/browser/pagetemplatefile.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/pagetemplatefile.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -70,7 +70,7 @@
pt_render = rebindFunction(PageTemplateFile.pt_render,
getEngine=getEngine)
- def _pt_getContext(self):
+ def pt_getContext(self):
try:
root = self.getPhysicalRoot()
view = self._getContext()
@@ -94,11 +94,8 @@
'request': request,
'modules': ModuleImporter,
}
- if view:
+ if view is not None:
c['view'] = view
c['views'] = ViewMapper(here, request)
return c
-
- pt_getContext = rebindFunction(_pt_getContext,
- SecureModuleImporter=ModuleImporter)
Modified: Products.Five/branches/zope33-port/browser/resource.py
===================================================================
--- Products.Five/branches/zope33-port/browser/resource.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/resource.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -23,12 +23,12 @@
from OFS.Traversable import Traversable as OFSTraversable
from zope.interface import implements
+from zope.component import getMultiAdapter
from zope.component.interfaces import IResource
from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.traversing.browser.interfaces import IAbsoluteURL
+from zope.datetime import time as timeFromDateTimeString
-from zope.app import zapi
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
-from zope.app.datetimeutils import time as timeFromDateTimeString
from zope.app.publisher.fileresource import File, Image
from zope.app.publisher.pagetemplateresource import PageTemplate
from zope.app.publisher.browser.resources import empty
@@ -51,7 +51,7 @@
# TODO Zope 3 uses site = getSite() instead of container here
# and the @@ resource access view
- url = str(zapi.getMultiAdapter((container, self.request), IAbsoluteURL))
+ url = str(getMultiAdapter((container, self.request), IAbsoluteURL))
url = urllib.unquote(url)
if not isinstance(container, DirectoryResource):
name = '++resource++%s' % name
Modified: Products.Five/branches/zope33-port/browser/tests/pages.txt
===================================================================
--- Products.Five/branches/zope33-port/browser/tests/pages.txt 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/tests/pages.txt 2006-04-27 20:37:46 UTC (rev 67668)
@@ -194,12 +194,12 @@
This tests security on a low level (functional pages test has
high-level security tests). Let's manually look up a protected view:
+ >>> from zope.component import getMultiAdapter
+ >>> from zope.publisher.browser import setDefaultSkin
>>> from Products.Five.traversable import FakeRequest
- >>> from zope.app import zapi
- >>> from zope.app.publication.browser import setDefaultSkin
>>> request = FakeRequest()
>>> setDefaultSkin(request)
- >>> view = zapi.getMultiAdapter((self.folder.testoid, request), name=u'eagle.txt')
+ >>> view = getMultiAdapter((self.folder.testoid, request), name=u'eagle.txt')
It's protecting the object with the permission, and not the attribute,
so we get ('',) instead of ('eagle',):
Copied: Products.Five/branches/zope33-port/browser/tests/skin.py (from rev 67662, Products.Five/branches/philikon-local-components/browser/tests/skin.py)
Modified: Products.Five/branches/zope33-port/browser/tests/skin.zcml
===================================================================
--- Products.Five/branches/zope33-port/browser/tests/skin.zcml 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/tests/skin.zcml 2006-04-27 20:37:46 UTC (rev 67668)
@@ -5,11 +5,10 @@
<!-- make the zope2.Public permission work -->
<meta:redefinePermission from="zope2.Public" to="zope.Public" />
- <browser:layer name="test" />
-
- <browser:skin
+ <interface
+ interface=".skin.ITestSkin"
+ type="zope.publisher.interfaces.browser.IBrowserSkinType"
name="TestSkin"
- layers="test default"
/>
<browser:page
@@ -18,7 +17,7 @@
attribute="eagle"
name="eagle.html"
permission="zope2.Public"
- layer="test"
+ layer=".skin.ITestSkin"
/>
</configure>
Modified: Products.Five/branches/zope33-port/browser/tests/test_absoluteurl.py
===================================================================
--- Products.Five/branches/zope33-port/browser/tests/test_absoluteurl.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/tests/test_absoluteurl.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -55,7 +55,7 @@
interface:
>>> from zope.interface import directlyProvides, providedBy
- >>> from zope.app.traversing.interfaces import IContainmentRoot
+ >>> from zope.traversing.interfaces import IContainmentRoot
>>> directlyProvides(self.folder, IContainmentRoot)
>>> for crumb in view.breadcrumbs():
Modified: Products.Five/branches/zope33-port/browser/tests/test_menu.py
===================================================================
--- Products.Five/branches/zope33-port/browser/tests/test_menu.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/browser/tests/test_menu.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -38,7 +38,7 @@
Now for some actual testing... Let's look up the menu we registered:
>>> from Products.Five.traversable import FakeRequest
- >>> from zope.app.publication.browser import setDefaultSkin
+ >>> from zope.publisher.browser import setDefaultSkin
>>> from zope.app.publisher.browser.menu import getMenu
>>> request = FakeRequest()
Copied: Products.Five/branches/zope33-port/component (from rev 67662, Products.Five/branches/philikon-local-components/component)
Modified: Products.Five/branches/zope33-port/configure.zcml
===================================================================
--- Products.Five/branches/zope33-port/configure.zcml 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/configure.zcml 2006-04-27 20:37:46 UTC (rev 67668)
@@ -6,6 +6,8 @@
<include file="i18n.zcml" />
<include file="event.zcml"/>
<include file="deprecated.zcml"/>
+ <include file="traversing.zcml"/>
+ <include package=".component" />
<include package=".site" />
<include package=".browser" />
<include package=".form" />
@@ -13,28 +15,6 @@
<include package=".skin" />
<include package=".utilities" />
- <include package="zope.app.event" />
- <include package="zope.app.traversing" />
-
- <!-- do 'traditional' traversing by default; needed by ZPT -->
- <adapter
- for="*"
- factory=".traversable.FiveTraversable"
- provides="zope.app.traversing.interfaces.ITraversable"
- />
-
- <adapter
- for="*"
- factory="zope.app.traversing.adapters.Traverser"
- provides="zope.app.traversing.interfaces.ITraverser"
- />
-
- <adapter
- for="*"
- factory=".viewable.BrowserDefault"
- provides=".interfaces.IBrowserDefault"
- />
-
<!-- this is really lying, but it's to please checkContainer -->
<five:implements class="OFS.ObjectManager.ObjectManager"
interface="zope.app.container.interfaces.IContainer" />
Modified: Products.Five/branches/zope33-port/event.zcml
===================================================================
--- Products.Five/branches/zope33-port/event.zcml 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/event.zcml 2006-04-27 20:37:46 UTC (rev 67668)
@@ -1,36 +1,19 @@
<configure xmlns="http://namespaces.zope.org/zope">
+ <!-- Enable object event dispatcher -->
+ <include package="zope.app.event" />
+
<!-- Adapter giving sublocations for ObjectManagers, used
by dispatchToSublocations -->
+ <adapter factory="OFS.subscribers.ObjectManagerSublocations" />
- <adapter
- for="OFS.interfaces.IObjectManager"
- provides="zope.app.location.interfaces.ISublocations"
- factory="OFS.subscribers.ObjectManagerSublocations"
- />
-
<!-- dispatch IObjectWillBeMovedEvent with "bottom-up" semantics -->
+ <subscriber handler="OFS.subscribers.dispatchObjectWillBeMovedEvent" />
- <subscriber
- for="OFS.interfaces.IItem
- OFS.interfaces.IObjectWillBeMovedEvent"
- handler="OFS.subscribers.dispatchObjectWillBeMovedEvent"
- />
-
<!-- dispatch IObjectMovedEvent with "top-down" semantics -->
+ <subscriber handler="OFS.subscribers.dispatchObjectMovedEvent" />
- <subscriber
- for="OFS.interfaces.IItem
- zope.app.container.interfaces.IObjectMovedEvent"
- handler="OFS.subscribers.dispatchObjectMovedEvent"
- />
-
<!-- dispatch IObjectClonedEvent with "top-down" semantics -->
+ <subscriber handler="OFS.subscribers.dispatchObjectClonedEvent" />
- <subscriber
- for="OFS.interfaces.IItem
- OFS.interfaces.IObjectClonedEvent"
- handler="OFS.subscribers.dispatchObjectClonedEvent"
- />
-
</configure>
Modified: Products.Five/branches/zope33-port/fiveconfigure.py
===================================================================
--- Products.Five/branches/zope33-port/fiveconfigure.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/fiveconfigure.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -28,15 +28,15 @@
from zope.interface import classImplements, classImplementsOnly, implementedBy
from zope.interface.interface import InterfaceClass
+from zope.component import getUtility
+from zope.component.interface import provideInterface
+from zope.component.zcml import adapter
from zope.configuration import xmlconfig
from zope.configuration.exceptions import ConfigurationError
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.security.interfaces import IPermission
-from zope.app import zapi
-from zope.app.component.interface import provideInterface
-from zope.app.component.metaconfigure import adapter
-from zope.app.security.interfaces import IPermission
-
+from Products.Five import isFiveMethod
from Products.Five.viewable import Viewable
from Products.Five.traversable import Traversable
from Products.Five.bridge import fromZ2Interface
@@ -108,9 +108,6 @@
interface)
)
-def isFiveMethod(m):
- return hasattr(m, '__five_method__')
-
_traversable_monkies = []
def classTraversable(class_):
# If a class already has this attribute, it means it is either a
@@ -227,7 +224,7 @@
def _registerClass(class_, meta_type, permission, addview, icon, global_):
setattr(class_, 'meta_type', meta_type)
- permission_obj = zapi.getUtility(IPermission, permission)
+ permission_obj = getUtility(IPermission, permission)
if icon:
setattr(class_, 'icon', '++resource++%s' % icon)
Modified: Products.Five/branches/zope33-port/fivedirectives.py
===================================================================
--- Products.Five/branches/zope33-port/fivedirectives.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/fivedirectives.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -17,12 +17,10 @@
"""
from zope.interface import Interface
from zope.app.publisher.browser.metadirectives import IBasicResourceInformation
-from zope.app.security.fields import Permission
+from zope.security.zcml import Permission
from zope.configuration.fields import GlobalObject, Tokens, PythonIdentifier
from zope.configuration.fields import Bool
-from zope.schema import ASCII
-from zope.schema import TextLine
-from zope.schema import BytesLine
+from zope.schema import ASCII, TextLine, BytesLine
class IImplementsDirective(Interface):
"""State that a class implements something.
Modified: Products.Five/branches/zope33-port/form/__init__.py
===================================================================
--- Products.Five/branches/zope33-port/form/__init__.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/form/__init__.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -21,17 +21,18 @@
import Acquisition
import transaction
from zope.event import notify
+from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
+from zope.location.interfaces import ILocation
+from zope.location import LocationProxy
from zope.schema.interfaces import ValidationError
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('zope')
-from zope.app.location.interfaces import ILocation
-from zope.app.location import LocationProxy
from zope.app.form.utility import setUpEditWidgets, applyWidgetsChanges
from zope.app.form.browser.submit import Update
from zope.app.form.interfaces import WidgetsError, MissingInputError
from zope.app.form.utility import setUpWidgets, getWidgetsData
from zope.app.form.interfaces import IInputWidget, WidgetsError
-from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
-from zope.app.i18n import ZopeMessageFactory as _
from Products.Five.browser import BrowserView
from Products.Five.browser.decode import processInputs, setPageEncoding
Modified: Products.Five/branches/zope33-port/form/metaconfigure.py
===================================================================
--- Products.Five/branches/zope33-port/form/metaconfigure.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/form/metaconfigure.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -18,14 +18,15 @@
import ExtensionClass
from Globals import InitializeClass as initializeClass
+import zope.component
from zope.interface import Interface
from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('zope')
-from zope.app import zapi
from zope.app.publisher.browser.menumeta import menuItemDirective
from zope.app.form.browser.metaconfigure import BaseFormDirective
from zope.app.container.interfaces import IAdding
-from zope.app.i18n import ZopeMessageFactory as _
from Products.Five.form import EditView, AddView
from Products.Five.metaclass import makeClass
@@ -53,8 +54,8 @@
if layer is None:
layer = IDefaultBrowserLayer
- s = zapi.getGlobalSiteManager()
- s.provideAdapter((for_, layer), Interface, name, class_)
+ s = zope.component.getGlobalSiteManager()
+ s.registerAdapter(class_, (for_, layer), Interface, name)
# Reminder: the permission we got has already been processed by
# BaseFormDirective, that means that zope.Public has been
@@ -116,8 +117,8 @@
if layer is None:
layer = IDefaultBrowserLayer
- s = zapi.getGlobalSiteManager()
- s.provideAdapter((for_, layer), Interface, name, class_)
+ s = zope.component.getGlobalSiteManager()
+ s.registerAdapter(class_, (for_, layer), Interface, name)
# Reminder: the permission we got has already been processed by
# BaseFormDirective, that means that zope.Public has been
Modified: Products.Five/branches/zope33-port/form/tests/test_forms.py
===================================================================
--- Products.Five/branches/zope33-port/form/tests/test_forms.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/form/tests/test_forms.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -41,16 +41,16 @@
>>> salutation = salutation.bind(request)
>>> contactname = contactname.bind(request)
- >>> from zope.app import zapi
+ >>> from zope.component import getMultiAdapter
>>> from zope.app.form.interfaces import IInputWidget
>>> from zope.app.form.browser.textwidgets import TextWidget
>>> from zope.app.form.browser.itemswidgets import DropdownWidget
- >>> view1 = zapi.getMultiAdapter((contactname, request), IInputWidget)
+ >>> view1 = getMultiAdapter((contactname, request), IInputWidget)
>>> view1.__class__ == TextWidget
True
- >>> view2 = zapi.getMultiAdapter((salutation, request), IInputWidget)
+ >>> view2 = getMultiAdapter((salutation, request), IInputWidget)
>>> view2.__class__ == DropdownWidget
True
Modified: Products.Five/branches/zope33-port/formlib/formbase.py
===================================================================
--- Products.Five/branches/zope33-port/formlib/formbase.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/formlib/formbase.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -19,10 +19,10 @@
import Acquisition
import zope.event
-import zope.app.event.objectevent
+import zope.lifecycleevent
from zope import interface
from zope.formlib import interfaces, form, namedtemplate
-from zope.app.i18n import ZopeMessageFactory as _
+from zope.formlib.i18n import _
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
from Products.Five.browser.decode import processInputs, setPageEncoding
@@ -59,7 +59,7 @@
self.context, self.form_fields, data, self.adapters):
zope.event.notify(
- zope.app.event.objectevent.ObjectModifiedEvent(self.context)
+ zope.lifecycleevent.ObjectModifiedEvent(self.context)
)
# TODO: Needs locale support. See also Five.form.EditView.
self.status = _(
Modified: Products.Five/branches/zope33-port/i18n.py
===================================================================
--- Products.Five/branches/zope33-port/i18n.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/i18n.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -20,15 +20,10 @@
from zope.i18n import interpolate
from zope.i18n.interfaces import ITranslationDomain, IUserPreferredLanguages
from zope.i18n.negotiator import normalize_lang
-from zope.app import zapi
+from zope.component import queryUtility
from zope.publisher.browser import BrowserLanguages
+from zope.i18nmessageid import Message
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageID, Message
-zope.deprecation.__show__.on()
-
class FiveTranslationService:
"""Translation service that delegates to ``zope.i18n`` machinery.
"""
@@ -36,12 +31,12 @@
# regarding fallback and Zope 2 compatability
def translate(self, domain, msgid, mapping=None,
context=None, target_language=None, default=None):
- if isinstance(msgid, (Message, MessageID)):
+ if isinstance(msgid, Message):
domain = msgid.domain
default = msgid.default
mapping = msgid.mapping
- util = zapi.queryUtility(ITranslationDomain, domain)
+ util = queryUtility(ITranslationDomain, domain)
if util is None:
# fallback to translation service that was registered,
Modified: Products.Five/branches/zope33-port/meta.zcml
===================================================================
--- Products.Five/branches/zope33-port/meta.zcml 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/meta.zcml 2006-04-27 20:37:46 UTC (rev 67668)
@@ -2,6 +2,13 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta">
+ <include package="zope.component" file="meta.zcml" />
+ <include package="zope.security" file="meta.zcml" />
+ <include package="zope.i18n" file="meta.zcml" />
+
+ <!-- BBB 2006/02/24, to be removed after 12 months -->
+ <include package="zope.modulealias" file="meta.zcml" />
+
<include package=".site" file="meta.zcml" />
<include package=".browser" file="meta.zcml" />
<include package=".form" file="meta.zcml" />
@@ -9,42 +16,13 @@
<meta:directives namespace="http://namespaces.zope.org/zope">
<meta:directive
- name="permission"
- schema="zope.app.security.metadirectives.IDefinePermissionDirective"
- handler="zope.app.security.metaconfigure.definePermission"
- />
-
- <meta:directive
- name="interface"
- schema="zope.app.component.metadirectives.IInterfaceDirective"
- handler="zope.app.component.metaconfigure.interface"
- />
-
- <meta:directive
name="view"
schema="zope.app.component.metadirectives.IViewDirective"
handler="zope.app.component.metaconfigure.view"
/>
+ <!-- BBB 2006/02/24, to be removed after 12 months -->
<meta:directive
- name="adapter"
- schema="zope.app.component.metadirectives.IAdapterDirective"
- handler="zope.app.component.metaconfigure.adapter"
- />
-
- <meta:directive
- name="subscriber"
- schema="zope.app.component.metadirectives.ISubscriberDirective"
- handler="zope.app.component.metaconfigure.subscriber"
- />
-
- <meta:directive
- name="utility"
- schema="zope.app.component.metadirectives.IUtilityDirective"
- handler="zope.app.component.metaconfigure.utility"
- />
-
- <meta:directive
name="factory"
schema="zope.app.component.metadirectives.IFactoryDirective"
handler="zope.app.component.metaconfigure.factory"
@@ -53,7 +31,7 @@
<meta:complexDirective
name="class"
schema="zope.app.component.metadirectives.IClassDirective"
- handler=".metaconfigure.ContentDirective"
+ handler=".metaconfigure.ClassDirective"
>
<meta:subdirective
@@ -73,6 +51,7 @@
</meta:complexDirective>
+ <!-- BBB 2006/02/24, to be removed after 12 months -->
<meta:complexDirective
name="content"
schema="zope.app.component.metadirectives.IClassDirective"
@@ -96,6 +75,7 @@
</meta:complexDirective>
+ <!-- BBB 2006/02/24, to be removed after 12 months -->
<meta:directive
name="vocabulary"
schema="zope.app.schema.metadirectives.IVocabularyDirective"
@@ -182,17 +162,4 @@
</meta:directives>
- <meta:directive
- name="redefinePermission"
- namespace="http://namespaces.zope.org/meta"
- schema="zope.app.security.metadirectives.IRedefinePermission"
- handler="zope.app.security.metaconfigure.redefinePermission"
- />
-
- <!-- load the zope:modulealias directive -->
- <include package="zope.modulealias" file="meta.zcml" />
-
- <!-- load the i18n:registerTranslations directive -->
- <include package="zope.app.i18n" file="meta.zcml" />
-
</configure>
Modified: Products.Five/branches/zope33-port/metaconfigure.py
===================================================================
--- Products.Five/branches/zope33-port/metaconfigure.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/metaconfigure.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -15,13 +15,12 @@
$Id$
"""
+import warnings
from Products.Five.security import CheckerPublic, protectName
from Globals import InitializeClass as initializeClass
+import zope.app.component.contentdirective
-from zope.app.component.contentdirective import ContentDirective as \
- zope_app_ContentDirective
-
-class ContentDirective(zope_app_ContentDirective):
+class ClassDirective(zope.app.component.contentdirective.ClassDirective):
def __protectName(self, name, permission_id):
self.__context.action(
@@ -37,3 +36,13 @@
callable = initializeClass,
args = (self.__class,)
)
+
+# BBB 2006/02/24, to be removed after 12 months
+class ContentDirective(ClassDirective):
+
+ def __init__(self, _context, class_):
+ warnings.warn_explicit(
+ "The 'content' alias for the 'class' directive has been "
+ "deprecated and will be removed in Zope 2.12.\n",
+ DeprecationWarning, _context.info.file, _context.info.line)
+ super(ContentDirective, self).__init__(_context, class_)
Modified: Products.Five/branches/zope33-port/security.py
===================================================================
--- Products.Five/branches/zope33-port/security.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/security.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -19,9 +19,8 @@
from zope.component import queryUtility, getUtility
from zope.security.management import thread_local
from zope.security.interfaces import IInteraction, ISecurityPolicy
+from zope.security.interfaces import IPermission
from zope.security.simplepolicies import ParanoidSecurityPolicy
-from zope.app.security.interfaces import IPermission
-from zope.app import zapi
from AccessControl import ClassSecurityInfo, getSecurityManager
from Globals import InitializeClass as initializeClass
@@ -67,7 +66,7 @@
return True
if isinstance(permission, StringTypes):
- permission = zapi.queryUtility(IPermission, unicode(permission))
+ permission = queryUtility(IPermission, unicode(permission))
if permission is None:
return False
Modified: Products.Five/branches/zope33-port/site/browser.py
===================================================================
--- Products.Five/branches/zope33-port/site/browser.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/browser.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -19,8 +19,7 @@
from zope.app.component.hooks import clearSite
from Products.Five.browser import BrowserView
-from Products.Five.site.localsite import enableLocalSiteHook, \
- disableLocalSiteHook
+from Products.Five.component import enableSite, disableSite
class LocalSiteView(BrowserView):
"""View for convering a possible site to a site
@@ -41,7 +40,7 @@
if self.isSite():
raise ValueError('This is already a site')
- enableLocalSiteHook(self.context)
+ enableSite(self.context)
return "This object is now a site"
def unmakeSite(self):
@@ -49,7 +48,7 @@
if not self.isSite():
raise ValueError('This is not a site')
- disableLocalSiteHook(self.context)
+ disableSite(self.context)
# disableLocalSiteHook circumcised our context so that it's
# not an ISite anymore. That can mean that certain things for
Modified: Products.Five/branches/zope33-port/site/configure.zcml
===================================================================
--- Products.Five/branches/zope33-port/site/configure.zcml 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/configure.zcml 2006-04-27 20:37:46 UTC (rev 67668)
@@ -2,28 +2,11 @@
xmlns:browser="http://namespaces.zope.org/browser">
<adapter
- for="*"
- provides="zope.component.interfaces.ISiteManager"
- factory=".localsite.siteManagerAdapter"
- />
-
- <adapter
- for="zope.app.site.interfaces.ISite"
+ for="zope.app.component.interfaces.ISite"
provides=".interfaces.IFiveUtilityRegistry"
factory=".utility.SimpleLocalUtilityRegistry"
/>
- <subscriber
- for="zope.app.component.interfaces.ISite
- zope.app.publication.interfaces.IBeforeTraverseEvent"
- handler="zope.app.component.site.threadSiteSubscriber"
- />
-
- <subscriber
- for="zope.app.publication.interfaces.IEndRequestEvent"
- handler="zope.app.component.site.clearThreadSiteSubscriber"
- />
-
<browser:page
for="zope.app.component.interfaces.IPossibleSite"
name="manage_site.html"
Modified: Products.Five/branches/zope33-port/site/interfaces.py
===================================================================
--- Products.Five/branches/zope33-port/site/interfaces.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/interfaces.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -16,7 +16,7 @@
$Id: interfaces.py 18584 2005-10-14 17:13:27Z regebro $
"""
from zope.interface import Interface, Attribute
-from zope.component.interfaces import ISiteManager
+from zope.component.interfaces import IComponentLookup
class IRegisterUtilitySimply(Interface):
"""Register utilities simply
@@ -76,7 +76,7 @@
returned.
"""
-class IFiveSiteManager(ISiteManager, IRegisterUtilitySimply):
+class IFiveSiteManager(IComponentLookup, IRegisterUtilitySimply):
"""Five site manager
For the sake of forward-portability, registering utilities can be
@@ -84,12 +84,3 @@
utility service (this corresponds to Zope 3.1's understanding of
site managers). An implementation of this interface will probably
delegate the work to an IFiveUtilityService component, though."""
-
-
-# BBB 2005/11/01 -- gone in Five 1.5.
-IFiveUtilityService = IFiveUtilityRegistry
-import zope.deprecation
-zope.deprecation.deprecated(
- 'IFiveUtilityService', "'IFiveUtilityService' has been renamed to "
- "'IFiveUtilityRegistry' and will disappear in Five 1.5."
- )
Modified: Products.Five/branches/zope33-port/site/localsite.py
===================================================================
--- Products.Five/branches/zope33-port/site/localsite.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/localsite.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -15,78 +15,13 @@
$Id$
"""
-from zope.event import notify
-from zope.interface import directlyProvides, directlyProvidedBy
from zope.interface import implements
from zope.component import getGlobalSiteManager
-from zope.component.exceptions import ComponentLookupError
-
+from zope.component.interfaces import ComponentLookupError
from zope.app.component.interfaces import ISite, IPossibleSite
-from zope.app.publication.zopepublication import BeforeTraverseEvent
-
-from ExtensionClass import Base
-from Acquisition import aq_base, aq_inner, aq_parent
-from Products.SiteAccess.AccessRule import AccessRule
-from ZPublisher.BeforeTraverse import registerBeforeTraverse
-from ZPublisher.BeforeTraverse import unregisterBeforeTraverse
-
+from Acquisition import aq_parent, aq_inner
from Products.Five.site.interfaces import IFiveSiteManager, IFiveUtilityRegistry
-# Hook up custom component architecture calls
-import zope.app.component.hooks
-zope.app.component.hooks.setHooks()
-
-def siteManagerAdapter(ob):
- """An adapter * -> ISiteManager.
-
- This is registered in place of the one in Zope 3 so that we lookup
- using acquisition instead of ILocation.
- """
- current = ob
- while True:
- if ISite.providedBy(current):
- return current.getSiteManager()
- current = getattr(current, '__parent__', aq_parent(aq_inner(current)))
- if current is None:
- # It does not support acquisition or has no parent, so we
- # return the global site
- return getGlobalSiteManager()
-
-HOOK_NAME = '__local_site_hook__'
-
-class LocalSiteHook(Base):
- def __call__(self, container, request):
- notify(BeforeTraverseEvent(container, request))
-
-
-def enableLocalSiteHook(obj):
- """Install __before_traverse__ hook for Local Site
- """
- # We want the original object, not stuff in between, and no acquisition
- obj = aq_base(obj)
- if not IPossibleSite.providedBy(obj):
- raise TypeError, 'Must provide IPossibleSite'
- hook = AccessRule(HOOK_NAME)
- registerBeforeTraverse(obj, hook, HOOK_NAME, 1)
-
- if not hasattr(obj, HOOK_NAME):
- setattr(obj, HOOK_NAME, LocalSiteHook())
-
- directlyProvides(obj, ISite, directlyProvidedBy(obj))
-
-def disableLocalSiteHook(obj):
- """Remove __before_traverse__ hook for Local Site
- """
- # We want the original object, not stuff in between, and no acquisition
- obj = aq_base(obj)
- if not ISite.providedBy(obj):
- raise TypeError, 'Must provide ISite'
- unregisterBeforeTraverse(obj, HOOK_NAME)
- if hasattr(obj, HOOK_NAME):
- delattr(obj, HOOK_NAME)
-
- directlyProvides(obj, directlyProvidedBy(obj) - ISite)
-
class FiveSiteManager(object):
implements(IFiveSiteManager)
@@ -96,6 +31,13 @@
self.context = self.__parent__ = context
@property
+ def __bases__(self):
+ next = self.next
+ if next is None:
+ return ()
+ return (next,)
+
+ @property
def next(self):
obj = self.context
while obj is not None:
Modified: Products.Five/branches/zope33-port/site/metaconfigure.py
===================================================================
--- Products.Five/branches/zope33-port/site/metaconfigure.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/metaconfigure.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -20,7 +20,7 @@
from zope.interface import classImplements, classImplementsOnly, implementedBy
from zope.interface.interface import InterfaceClass
from zope.configuration.exceptions import ConfigurationError
-from zope.app.component.metaconfigure import adapter
+from zope.component.zcml import adapter
from zope.app.component.interfaces import IPossibleSite
from Products.Five.site.localsite import FiveSite
Modified: Products.Five/branches/zope33-port/site/tests/dummy.py
===================================================================
--- Products.Five/branches/zope33-port/site/tests/dummy.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/tests/dummy.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -15,7 +15,7 @@
$Id$
"""
-from zope.interface import implements, Interface
+from zope.interface import implements, implementsOnly, Interface
from OFS.SimpleItem import SimpleItem
from Products.Five.tests.testing import FiveTraversableFolder
@@ -25,7 +25,10 @@
class DummySite(FiveTraversableFolder):
"""A very dummy Site
"""
- implements(IDummySite)
+ # we specifically do not let this site inherit any interfaces from
+ # the superclasses so that this class does not implement
+ # IPossibleSite under any circumstances
+ implementsOnly(IDummySite)
def manage_addDummySite(self, id, REQUEST=None):
"""Add the dummy site."""
Modified: Products.Five/branches/zope33-port/site/tests/sitemanager.txt
===================================================================
--- Products.Five/branches/zope33-port/site/tests/sitemanager.txt 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/tests/sitemanager.txt 2006-04-27 20:37:46 UTC (rev 67668)
@@ -30,8 +30,8 @@
Let's make the possible site a real site:
- >>> from Products.Five.site.localsite import enableLocalSiteHook
- >>> enableLocalSiteHook(dummysite)
+ >>> from Products.Five.component import enableSite
+ >>> enableSite(dummysite)
and tell Zope 3 about it:
@@ -104,7 +104,7 @@
Let's get all the adapters for ``adaptable``:
- >>> zapi.getAdapters((adaptable,), IAdapted) #doctest: +ELLIPSIS
+ >>> list(zapi.getAdapters((adaptable,), IAdapted)) #doctest: +ELLIPSIS
[(u'', <Products.Five.tests.adapters.Adapter instance at ...>)]
@@ -118,7 +118,7 @@
Now we set the current site to the ``subsite``:
- >>> enableLocalSiteHook(subsite)
+ >>> enableSite(subsite)
>>> setSite(subsite)
When we call getServices() now, we get the correct site manager:
Modified: Products.Five/branches/zope33-port/site/tests/test_localsite.py
===================================================================
--- Products.Five/branches/zope33-port/site/tests/test_localsite.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/tests/test_localsite.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -23,14 +23,13 @@
import unittest
from Testing import ZopeTestCase
-from zope.interface import implements
-from zope.interface import directlyProvides, directlyProvidedBy
+import zope.interface
from zope.component import getGlobalSiteManager, getSiteManager
-from zope.component.exceptions import ComponentLookupError
-from zope.component.interfaces import ISiteManager
+from zope.component.interfaces import ComponentLookupError
+from zope.component.interfaces import IComponentLookup
+from zope.traversing.interfaces import IContainmentRoot
from zope.app.component.hooks import setSite, getSite, setHooks
from zope.app.component.interfaces import IPossibleSite, ISite
-from zope.app.traversing.interfaces import IContainmentRoot
from zope.app.testing.placelesssetup import PlacelessSetup
from Acquisition import Implicit
@@ -40,33 +39,32 @@
from Products.Five import zcml
class SiteManager(Implicit):
- implements(ISiteManager)
+ zope.interface.implements(IComponentLookup)
+ @property
+ def __bases__(self):
+ next = getattr(self, 'next', None)
+ if next is None:
+ return ()
+ return (next,)
+
class Folder(ObjectManager):
- implements(IPossibleSite)
- sm = None
-
- def getId(self):
- return self.id
-
- def getSiteManager(self, default=None):
- return self.sm
-
def setSiteManager(self, sm):
- self.sm = sm
- directlyProvides(self, ISite, directlyProvidedBy(self))
+ super(Folder, self).setSiteManager(sm)
+ zope.interface.alsoProvides(self, ISite)
class Package(Implicit):
pass
class Root(Folder):
- implements(IContainmentRoot, ISite)
+ zope.interface.implements(IContainmentRoot, ISite)
+
def getSiteManager(self):
return getGlobalSiteManager()
class SiteManagerStub(object):
- implements(ISiteManager)
+ zope.interface.implements(IComponentLookup)
class SiteManagerTest(PlacelessSetup, unittest.TestCase):
@@ -91,6 +89,7 @@
self.unrooted_subfolder = Folder().__of__(self.unparented_folder)
zcml.load_config("meta.zcml", Products.Five)
zcml.load_config("permissions.zcml", Products.Five)
+ zcml.load_config("configure.zcml", Products.Five.component)
zcml.load_config("configure.zcml", Products.Five.site)
zcml_text = """\
<five:localsite
@@ -165,29 +164,6 @@
# # Check that getGlobalSiteManager() is not proxied
# self.assert_(getNextSiteManager(sm) is getGlobalSiteManager())
- def test_siteManagerAdapter(self):
- from Products.Five.site.localsite import siteManagerAdapter
-
- # If it is a site, return the service service.
- sm = SiteManagerStub()
- site = Folder()
- site.setSiteManager(sm)
- self.assertEqual(siteManagerAdapter(site), sm)
-
- # If it has an acquisition context, "acquire" the site
- # and return the service service
- ob = Folder()
- ob = ob.__of__(site)
- self.assertEqual(siteManagerAdapter(ob), sm)
- ob2 = Folder()
- ob2 = ob2.__of__(ob)
- self.assertEqual(siteManagerAdapter(ob2), sm)
-
- # If it does we are unable to find a service service, raise
- # ComponentLookupError
- orphan = Folder()
- self.failUnless(siteManagerAdapter(orphan) is getGlobalSiteManager())
-
def test_setThreadSite_clearThreadSite(self):
from zope.app.component.site import threadSiteSubscriber, clearSite
from zope.app.publication.zopepublication import BeforeTraverseEvent
Modified: Products.Five/branches/zope33-port/site/tests/test_utility.py
===================================================================
--- Products.Five/branches/zope33-port/site/tests/test_utility.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/tests/test_utility.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -26,7 +26,7 @@
from zope.interface import directlyProvides
from zope.component import provideUtility
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.app import zapi
from zope.app.testing.placelesssetup import setUp, tearDown
from zope.app.component import getNextUtility
@@ -34,8 +34,8 @@
import Products.Five
from Products.Five import zcml
+from Products.Five.component import enableSite
from Products.Five.site.interfaces import IRegisterUtilitySimply
-from Products.Five.site.localsite import enableLocalSiteHook
from Products.Five.site.tests.dummy import manage_addDummySite, \
IDummyUtility, ISuperDummyUtility, DummyUtility
@@ -45,6 +45,7 @@
setUp()
zcml.load_config("meta.zcml", Products.Five)
zcml.load_config("permissions.zcml", Products.Five)
+ zcml.load_config("configure.zcml", Products.Five.component)
zcml.load_config("configure.zcml", Products.Five.site)
zcml_text = """\
<five:localsite
@@ -52,7 +53,7 @@
class="Products.Five.site.tests.dummy.DummySite" />"""
zcml.load_string(zcml_text)
manage_addDummySite(self.folder, 'site')
- enableLocalSiteHook(self.folder.site)
+ enableSite(self.folder.site)
setSite(self.folder.site)
# Hook up custom component architecture calls; we need to do
@@ -173,7 +174,7 @@
# let's also create a subsite and make that our site
manage_addDummySite(self.folder.site, 'subsite')
- enableLocalSiteHook(self.folder.site.subsite)
+ enableSite(self.folder.site.subsite)
setSite(self.folder.site.subsite)
# we should still be able to lookup the original utility from
@@ -249,7 +250,7 @@
# test local site vs. nested local site
manage_addDummySite(self.folder.site, 'subsite')
- enableLocalSiteHook(self.folder.site.subsite)
+ enableSite(self.folder.site.subsite)
setSite(self.folder.site.subsite)
sublocal_dummy = DummyUtility()
Modified: Products.Five/branches/zope33-port/site/utility.py
===================================================================
--- Products.Five/branches/zope33-port/site/utility.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/site/utility.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -17,7 +17,7 @@
"""
from zope.interface import implements
from zope.component import getGlobalSiteManager
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.app.component import getNextSiteManager
from Acquisition import aq_base
@@ -116,11 +116,3 @@
"%s with the name '%s'" % (interface.getName(),
name))
utilities._setObject(id, utility)
-
-# BBB 2005/11/01 -- gone in Five 1.5.
-SimpleLocalUtilityService = SimpleLocalUtilityRegistry
-import zope.deprecation
-zope.deprecation.deprecated(
- 'SimpleLocalUtilityService', "'SimpleLocalUtilityService' has been renamed to "
- "'SimpleLocalUtilityRegistry' and will disappear in Five 1.5."
- )
Modified: Products.Five/branches/zope33-port/sizeconfigure.py
===================================================================
--- Products.Five/branches/zope33-port/sizeconfigure.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/sizeconfigure.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -16,12 +16,13 @@
$Id$
"""
-from zope.app.size.interfaces import ISized
-from Products.Five.fiveconfigure import isFiveMethod
+from zope.size.interfaces import ISized
+from Products.Five import fivemethod, isFiveMethod
# holds classes that were monkeyed with; for clean up
_monkied = []
+ at fivemethod
def get_size(self):
size = ISized(self, None)
if size is not None:
@@ -32,8 +33,6 @@
if method is not None:
return self.__five_original_get_size()
-get_size.__five_method__ = True
-
def classSizable(class_):
"""Monkey the class to be sizable through Five"""
# tuck away the original method if necessary
Modified: Products.Five/branches/zope33-port/skin/standardmacros.py
===================================================================
--- Products.Five/branches/zope33-port/skin/standardmacros.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/skin/standardmacros.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -16,8 +16,7 @@
$Id$
"""
import zope.interface
-
-from zope.app import zapi
+import zope.component
from Products.Five.browser import BrowserView
# this is a verbatim copy of zope.app.basicskin except that it doesn't
@@ -37,7 +36,7 @@
context = self.context
request = self.request
for name in self.macro_pages:
- page = zapi.getMultiAdapter((context, request), name=name)
+ page = zope.component.getMultiAdapter((context, request), name=name)
try:
v = page[key]
except KeyError:
Modified: Products.Five/branches/zope33-port/tests/directives.zcml
===================================================================
--- Products.Five/branches/zope33-port/tests/directives.zcml 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/tests/directives.zcml 2006-04-27 20:37:46 UTC (rev 67668)
@@ -23,13 +23,6 @@
<five:traversable class="Products.Five.tests.testing.fancycontent.FancyContent" />
- <!-- Testing the vocabulary directive -->
-
- <vocabulary
- name="aVocabulary"
- factory="zope.schema.tests.test_vocabulary.SampleVocabulary"
- />
-
<!-- testing that products meta.zcml statements are picked up. -->
<include file="meta.zcml" />
Modified: Products.Five/branches/zope33-port/tests/event.txt
===================================================================
--- Products.Five/branches/zope33-port/tests/event.txt 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/tests/event.txt 2006-04-27 20:37:46 UTC (rev 67668)
@@ -25,9 +25,6 @@
A bit of setup for the tests. Because we'll test copy/paste, we need to
work inside a database::
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
-
>>> import ZODB.tests.util
>>> db = ZODB.tests.util.DB()
>>> connection = db.open()
@@ -58,7 +55,7 @@
framework's ones, so ours will be called first. This has the effect that
printed events will be in their "natural" order::
- >>> from zope.app.event.interfaces import IObjectEvent
+ >>> from zope.component.interfaces import IObjectEvent, IRegistrationEvent
>>> from zope.app.container.interfaces import IObjectMovedEvent
>>> from OFS.interfaces import IObjectWillBeMovedEvent
>>> from OFS.interfaces import IObjectClonedEvent
@@ -68,7 +65,8 @@
>>> def printObjectEventExceptSome(object, event):
... if (IObjectMovedEvent.providedBy(event) or
... IObjectWillBeMovedEvent.providedBy(event) or
- ... IObjectClonedEvent.providedBy(event)):
+ ... IObjectClonedEvent.providedBy(event) or
+ ... IRegistrationEvent.providedBy(event)):
... return
... print event.__class__.__name__, object.getId()
@@ -80,11 +78,12 @@
Finally we need to load the subscribers configuration::
- >>> from Products.Five import zcml
- >>> import Products.Five
- >>> import zope.app.component
- >>> zcml.load_config('meta.zcml', zope.app.component)
- >>> zcml.load_config('event.zcml', Products.Five)
+ >>> import zope.component
+ >>> import OFS.subscribers
+ >>> zope.component.provideAdapter(OFS.subscribers.ObjectManagerSublocations)
+ >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectWillBeMovedEvent)
+ >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectMovedEvent)
+ >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectClonedEvent)
We need at least one fake deprecated method to tell the compatibility
framework that component architecture is initialized::
@@ -465,4 +464,3 @@
>>> import transaction
>>> transaction.abort()
- >>> tearDown()
Modified: Products.Five/branches/zope33-port/tests/test_event.py
===================================================================
--- Products.Five/branches/zope33-port/tests/test_event.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/tests/test_event.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -28,6 +28,12 @@
from OFS.OrderedFolder import OrderedFolder
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
+from zope.component import testing, eventtesting
+
+def setUp(test):
+ testing.setUp(test)
+ eventtesting.setUp(test)
+
class DontComplain(object):
def _verifyObjectPaste(self, object, validate_src=1):
pass
@@ -82,7 +88,8 @@
def test_suite():
from zope.testing.doctest import DocFileSuite
- return DocFileSuite('event.txt', package="Products.Five.tests")
+ return DocFileSuite('event.txt', package="Products.Five.tests",
+ setUp=setUp, tearDown=testing.tearDown)
if __name__ == '__main__':
framework()
Modified: Products.Five/branches/zope33-port/tests/test_i18n.py
===================================================================
--- Products.Five/branches/zope33-port/tests/test_i18n.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/tests/test_i18n.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -19,18 +19,16 @@
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
+from zope.component.testing import setUp, tearDown
+
def test_directive():
"""
- Test the i18n directive
+ Test the i18n directive. First, we need to register the ZCML
+ directive:
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
-
- First, we need to register the ZCML directive:
-
- >>> import zope.app.i18n
+ >>> import zope.i18n
>>> from Products.Five import zcml
- >>> zcml.load_config('meta.zcml', zope.app.i18n)
+ >>> zcml.load_config('meta.zcml', zope.i18n)
Let's register the gettext locales using the ZCML directive:
@@ -56,16 +54,11 @@
u'This is an explicit message'
>>> translate(msg, target_language='de')
u'Dies ist eine explizite Nachricht'
-
-
- Clean up:
-
- >>> tearDown()
"""
def test_suite():
- from Testing.ZopeTestCase import ZopeDocTestSuite
- return ZopeDocTestSuite()
+ from zope.testing.doctest import DocTestSuite
+ return DocTestSuite(setUp=setUp, tearDown=tearDown)
if __name__ == '__main__':
framework()
Modified: Products.Five/branches/zope33-port/tests/test_security.py
===================================================================
--- Products.Five/branches/zope33-port/tests/test_security.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/tests/test_security.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -72,13 +72,13 @@
>>> configure_zcml = '''
... <configure xmlns="http://namespaces.zope.org/zope">
- ... <content class="Products.Five.tests.test_security.Dummy1">
+ ... <class class="Products.Five.tests.test_security.Dummy1">
... <allow attributes="foo" />
... <!--deny attributes="baz" /--> <!-- XXX not yet supported -->
... <require attributes="bar keg"
... permission="zope2.ViewManagementScreens"
... />
- ... </content>
+ ... </class>
... </configure>
... '''
>>> zcml.load_string(configure_zcml)
Modified: Products.Five/branches/zope33-port/tests/test_size.py
===================================================================
--- Products.Five/branches/zope33-port/tests/test_size.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/tests/test_size.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -20,7 +20,7 @@
execfile(os.path.join(sys.path[0], 'framework.py'))
from zope.interface import implements
-from zope.app.size.interfaces import ISized
+from zope.size.interfaces import ISized
class SimpleContentSize(object):
"""Size for ``SimpleContent`` objects."""
@@ -64,12 +64,12 @@
... <five:sizable class="Products.Five.tests.testing.fancycontent.FancyContent" />
... <adapter
... for="Products.Five.tests.testing.simplecontent.ISimpleContent"
- ... provides="zope.app.size.interfaces.ISized"
+ ... provides="zope.size.interfaces.ISized"
... factory="Products.Five.tests.test_size.SimpleContentSize"
... />
... <adapter
... for="Products.Five.tests.testing.fancycontent.IFancyContent"
- ... provides="zope.app.size.interfaces.ISized"
+ ... provides="zope.size.interfaces.ISized"
... factory="Products.Five.tests.test_size.FancyContentSize"
... />
... </configure>'''
Modified: Products.Five/branches/zope33-port/traversable.py
===================================================================
--- Products.Five/branches/zope33-port/traversable.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/traversable.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -19,16 +19,15 @@
from zope.interface import implements, Interface
from zope.publisher.interfaces import ILayer
from zope.publisher.interfaces.browser import IBrowserRequest
-
-from zope.app.traversing.interfaces import ITraverser, ITraversable
-from zope.app.traversing.adapters import DefaultTraversable
-from zope.app.traversing.adapters import traversePathElement
-from zope.app.publication.browser import setDefaultSkin
+from zope.publisher.browser import setDefaultSkin
+from zope.traversing.interfaces import ITraverser, ITraversable
+from zope.traversing.adapters import DefaultTraversable
+from zope.traversing.adapters import traversePathElement
from zope.app.interface import queryType
import Products.Five.security
+from Products.Five import fivemethod
from zExceptions import NotFound
-from ZPublisher import xmlrpc
class FakeRequest(dict):
implements(IBrowserRequest)
@@ -44,6 +43,7 @@
"""
__five_traversable__ = True
+ @fivemethod
def __bobo_traverse__(self, REQUEST, name):
"""Hook for Zope 2 traversal
@@ -114,9 +114,6 @@
raise AttributeError(name)
- __bobo_traverse__.__five_method__ = True
-
-
class FiveTraversable(DefaultTraversable):
def traverse(self, name, furtherPath):
Copied: Products.Five/branches/zope33-port/traversing.zcml (from rev 67662, Products.Five/branches/philikon-local-components/traversing.zcml)
Modified: Products.Five/branches/zope33-port/utilities/browser/tests/test_marker.py
===================================================================
--- Products.Five/branches/zope33-port/utilities/browser/tests/test_marker.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/utilities/browser/tests/test_marker.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -60,7 +60,7 @@
>>> from Products.Five.tests.testing.simplecontent import ISimpleContent
>>> class IFooMarker(ISimpleContent): pass
- >>> from zope.app.component.interface import provideInterface
+ >>> from zope.component.interface import provideInterface
>>> provideInterface('', IFooMarker)
>>> view.getAvailableInterfaceNames()
[...IFooMarker...]
Modified: Products.Five/branches/zope33-port/utilities/marker.py
===================================================================
--- Products.Five/branches/zope33-port/utilities/marker.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/utilities/marker.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -19,14 +19,11 @@
"""
from sets import Set
-from zope.interface import implements
-from zope.interface import implementedBy
-from zope.interface import directlyProvidedBy
-from zope.interface import directlyProvides
-from zope.interface import providedBy
+from zope.interface import implements, implementedBy, providedBy
+from zope.interface import directlyProvides, directlyProvidedBy
from zope.interface.interfaces import IInterface
-from zope.app.component.interface import getInterface, interfaceToName
-from zope.app.component.interface import searchInterface
+from zope.component.interface import getInterface, interfaceToName
+from zope.component.interface import searchInterface
from interfaces import IMarkerInterfaces
Modified: Products.Five/branches/zope33-port/viewable.py
===================================================================
--- Products.Five/branches/zope33-port/viewable.py 2006-04-27 20:37:24 UTC (rev 67667)
+++ Products.Five/branches/zope33-port/viewable.py 2006-04-27 20:37:46 UTC (rev 67668)
@@ -20,8 +20,9 @@
from zope.component import ComponentLookupError
from zope.interface import implements
from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.app.zapi import getDefaultViewName
+from zope.app.publisher.browser import getDefaultViewName
+from Products.Five import fivemethod
from Products.Five.traversable import FakeRequest
from Products.Five.interfaces import IBrowserDefault
@@ -45,6 +46,7 @@
# return self
# we have a default view, tell zpublisher to go there
+ @fivemethod
def __browser_default__(self, request):
obj = self
path = None
@@ -59,11 +61,11 @@
return obj, ('fallback_call__',)
return obj, path
return self.__fallback_default__(request)
- __browser_default__.__five_method__ = True
# this is technically not needed because ZPublisher finds our
# attribute through __browser_default__; but we also want to be
# able to call pages from python modules, PythonScripts or ZPT
+ # @fivemethod
# def __call__(self, *args, **kw):
# """ """
# request = kw.get('REQUEST')
@@ -77,7 +79,6 @@
# if meth is not None:
# return meth(*args, **kw)
# return self.fallback_call__(*args, **kw)
- # __call__.__five_method__ = True
# def simpleRecursion():
# # This tests for simple recursion, which can easily happen
More information about the Zope-Checkins
mailing list