[Zope3-checkins] SVN: Zope3/trunk/ Addressed issue 295 as suggested.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sun Feb 27 19:16:22 EST 2005
Log message for revision 29338:
Addressed issue 295 as suggested.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/doc/TODO.txt
U Zope3/trunk/src/zope/app/component/meta.zcml
U Zope3/trunk/src/zope/app/component/metaconfigure.py
U Zope3/trunk/src/zope/app/component/metadirectives.py
U Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
U Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/doc/CHANGES.txt 2005-02-28 00:16:22 UTC (rev 29338)
@@ -288,6 +288,12 @@
Restructuring
+ - Addressed issue 295: Sort out defaultView.
+
+ Deprecated `zope:defaultView` directive and removed unused default
+ view handler in `zope.app.publisher.browser.viewmeta`. Added a `layer`
+ attribute to the `browser:defaultView` directive.
+
- zope.component.createObject no longer accepts a positional
context argument. A context can be provided as a keyword argument.
Modified: Zope3/trunk/doc/TODO.txt
===================================================================
--- Zope3/trunk/doc/TODO.txt 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/doc/TODO.txt 2005-02-28 00:16:22 UTC (rev 29338)
@@ -11,8 +11,6 @@
- Support for iterable sources
-- Issue 295: Sort out defaultView
-
- Allow adapters (including views) to be registered for classes
(really implementation specifications of classes) as well as
interfaces. This has been done for page directives but needs to be
@@ -62,7 +60,7 @@
* 319: Navigation with anonymous
-* 321: TravelsalError after renaming or moving Sites with local services
+* 321: TraversalError after renaming or moving Sites with local services
* 323: Permission zope.Public in addfrom does not work
Modified: Zope3/trunk/src/zope/app/component/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/component/meta.zcml 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/src/zope/app/component/meta.zcml 2005-02-28 00:16:22 UTC (rev 29338)
@@ -41,6 +41,7 @@
handler="zope.app.component.metaconfigure.view"
/>
+ <!-- BBB: Deprecated. Will go away in 3.3 -->
<meta:directive
name="defaultView"
schema=".metadirectives.IDefaultViewDirective"
Modified: Zope3/trunk/src/zope/app/component/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/component/metaconfigure.py 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/src/zope/app/component/metaconfigure.py 2005-02-28 00:16:22 UTC (rev 29338)
@@ -418,6 +418,8 @@
args = ('', iface)
)
+############################################################################
+# BBB: Deprecated. Will go away in 3.3.
def defaultView(_context, type, name, for_):
_context.action(
@@ -439,6 +441,13 @@
args = ('', for_)
)
+from zope.deprecation import deprecated
+deprecated('defaultView',
+ 'The zope:defaultView directive has been deprecated in favor of '
+ 'the browser:defaultView directive. '
+ 'Will be gone in X3.3.')
+############################################################################
+
def defaultLayer(_context, type, layer):
_context.action(
discriminator=('defaultLayer', type, layer),
Modified: Zope3/trunk/src/zope/app/component/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/component/metadirectives.py 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/src/zope/app/component/metadirectives.py 2005-02-28 00:16:22 UTC (rev 29338)
@@ -326,6 +326,8 @@
value_type=zope.configuration.fields.GlobalObject(),
)
+############################################################################
+# BBB: Deprecated; use browser:defaultView instead. Will go away in 3.3.
class IDefaultViewDirective(IBasicResourceInformation):
"""The name of the view that should be the default.
@@ -343,6 +345,7 @@
for all objects."""),
required=False,
)
+############################################################################
class IResourceDirective(IBasicComponentInformation,
Modified: Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py 2005-02-28 00:16:22 UTC (rev 29338)
@@ -332,15 +332,13 @@
args = (name, _context.info)
)
-def defaultView(_context, name, for_=None):
+def defaultView(_context, name, for_=None, layer=IBrowserRequest):
- type = IBrowserRequest
-
_context.action(
discriminator = ('defaultViewName', for_, type, name),
callable = handler,
args = ('provideAdapter',
- (for_, type), IDefaultViewName, '', name, _context.info)
+ (for_, layer), IDefaultViewName, '', name, _context.info)
)
if for_ is not None:
Modified: Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py 2005-02-28 00:16:22 UTC (rev 29338)
@@ -175,6 +175,13 @@
required=False
)
+ layer = LayerField(
+ title=u"The layer the default view is declared for",
+ description=u"The default layer for which the default view is "
+ u"applicable. By default it is applied to all layers.",
+ required=False
+ )
+
#
# browser pages
#
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py 2005-02-28 00:16:22 UTC (rev 29338)
@@ -22,6 +22,7 @@
from zope.interface import Interface, implements, directlyProvides, providedBy
import zope.security.management
+from zope.component.interfaces import IDefaultViewName
from zope.configuration.xmlconfig import xmlconfig, XMLConfig
from zope.configuration.exceptions import ConfigurationError
from zope.publisher.browser import TestRequest
@@ -253,8 +254,9 @@
self.assertEqual(v(), "<html><body><p>test</p></body></html>\n")
def testDefaultView(self):
- self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
- None)
+ self.assertEqual(
+ zapi.queryMultiAdapter((ob, request), IDefaultViewName),
+ None)
xmlconfig(StringIO(template % (
'''
@@ -266,6 +268,34 @@
self.assertEqual(zapi.getDefaultViewName(ob, request), 'test')
+ def testDefaultViewWithLayer(self):
+ class FakeRequest(TestRequest):
+ implements(ITestLayer)
+ request2 = FakeRequest()
+
+ self.assertEqual(
+ zapi.queryMultiAdapter((ob, request2), IDefaultViewName),
+ None)
+
+ xmlconfig(StringIO(template % (
+ '''
+ <browser:defaultView
+ name="test"
+ for="zope.app.component.tests.views.IC" />
+
+ <browser:defaultView
+ name="test2"
+ for="zope.app.component.tests.views.IC"
+ layer="
+ zope.app.publisher.browser.tests.test_directives.ITestLayer"
+ />
+ '''
+ )))
+
+ self.assertEqual(zapi.getDefaultViewName(ob, request2), 'test2')
+ self.assertEqual(zapi.getDefaultViewName(ob, request), 'test')
+
+
def testSkinResource(self):
self.assertEqual(
zapi.queryAdapter(Request(IV), name='test'), None)
Modified: Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2005-02-27 23:58:56 UTC (rev 29337)
+++ Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2005-02-28 00:16:22 UTC (rev 29338)
@@ -357,23 +357,6 @@
menu, title
)
-def defaultView(_context, name, for_=None):
-
- _context.action(
- discriminator = ('defaultViewName', for_, IBrowserRequest, name),
- callable = handler,
- args = ('provideAdapter',
- (for_, IBrowserRequest), IDefaultViewName, '', name,
- _context.info)
- )
-
- if for_ is not None:
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = ('', for_)
- )
-
# transient _handle_menu registry
_registeredMenus = {}
More information about the Zope3-Checkins
mailing list