Commit c4c1b4ac authored by Hanno Schlichting's avatar Hanno Schlichting

Retire the manage_interfaces ZMI screens.

parent 4c668817
......@@ -118,26 +118,24 @@ class Item(Base,
__name__ = ComputedAttribute(lambda self: self.id)
# Meta type used for selecting all objects of a given type.
meta_type='simple item'
meta_type = 'simple item'
# Default title.
title=''
title = ''
# Default propertysheet info:
__propsets__=()
__propsets__ = ()
manage_options=(
UndoSupport.manage_options
+ Owned.manage_options
+ ({'label': 'Interfaces',
'action': 'manage_interfaces'},)
)
manage_options = (
UndoSupport.manage_options +
Owned.manage_options
)
# Attributes that must be acquired
REQUEST = Acquired
# Allow (reluctantly) access to unprotected attributes
__allow_access_to_unprotected_subobjects__=1
__allow_access_to_unprotected_subobjects__ = 1
def title_or_id(self):
"""Return the title if it is not blank and the id otherwise.
......
......@@ -302,14 +302,6 @@ class FileTests(unittest.TestCase):
'come to the aid of the Party.')
self.assertTrue('Party' in self.file.PrincipiaSearchSource())
def testFindFile(self):
self.file.manage_edit('foobar', 'text/plain',
filedata='Now is the time for all good men to '
'come to the aid of the Party.')
results = self.app.ZopeFind(self.app, obj_searchterm='Party')
self.assertEqual(len(results), 1)
self.assertEqual(results[0][1], self.file)
def test_interfaces(self):
from zope.interface.verify import verifyClass
from OFS.Image import File
......
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
<browser:page
for="*"
name="edit-markers.html"
template="edit_markers.pt"
class="Products.Five.utilities.browser.marker.EditView"
permission="zope2.ManageProperties"
/>
<browser:page
for="*"
name="manage_interfaces"
template="manage_interfaces.pt"
class="Products.Five.utilities.browser.marker.EditView"
permission="zope2.ManageProperties"
/>
</configure>
<html metal:use-macro="context/@@standard_macros/page">
<body>
<metal:slot metal:fill-slot="body">
<metal:macro metal:define-macro="heading">
<h1 i18n:translate="heading_edit_marker">Assign Marker Interfaces</h1>
</metal:macro>
<metal:macro metal:define-macro="main">
<p class="form-help formHelp" i18n:translate="">Change the behavior of this
object by adding or removing marker interfaces. You can choose one or more
interfaces to be added to the list of provided interfaces for this
object.</p>
<p class="form-help formHelp" i18n:translate="">A marker interface is used to
identify an instance of a piece of content. When in conjunction with Five,
this allows you to enable and disable views based on marker interfaces for
example.</p>
<form action="." method="post"
tal:attributes="action request/ACTUAL_URL">
<fieldset>
<legend i18n:translate="legend_provided">Provided Interfaces</legend>
<tal:loop tal:repeat="interface view/getInterfaceNames">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<label class="form-mono"
tal:content="interface/name">INTERFACE</label><br />
</tal:loop>
<tal:loop tal:repeat="interface view/getDirectlyProvidedNames">
<input type="checkbox" id="INTERFACE" name="remove:list"
tal:attributes="id interface/name; value interface/name" />
<label class="form-mono" for="INTERFACE" tal:attributes="for interface/name"
tal:content="interface/name">INTERFACE</label><br />
</tal:loop>
<tal:case tal:condition="view/getDirectlyProvidedNames">
<div class="formControls FormButtons">
<input class="form-element" type="submit" name="SAVE" value="Remove"
i18n:attributes="value" />
</div>
</tal:case>
</fieldset>
<fieldset>
<legend i18n:translate="legend_available_marker">Available Marker
Interfaces</legend>
<tal:loop tal:repeat="interface view/getAvailableInterfaceNames">
<input type="checkbox" id="INTERFACE" name="add:list"
tal:attributes="id interface/name; value interface/name" />
<label class="form-mono" for="INTERFACE" tal:attributes="for interface/name"
tal:content="interface/name">INTERFACE</label><br />
</tal:loop>
<div class="formControls FormButtons">
<input class="form-element" type="submit" name="SAVE" value="Add"
i18n:attributes="value" />
</div>
</fieldset>
</form>
</metal:macro>
</metal:slot>
</body>
</html>
<h1 tal:replace="structure context/manage_page_header">PAGE HEADER</h1>
<h2 tal:replace="structure context/manage_tabs">TABS</h2>
<style type="text/css">
fieldset {width:auto; float:left}
</style>
<metal:macro metal:use-macro="context/@@edit-markers.html/main" />
<h1 tal:replace="structure context/manage_page_footer">PAGE FOOTER</h1>
##############################################################################
#
# Copyright (c) 2004, 2005 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Marker interfaces adapter views.
"""
from Products.Five.utilities.interfaces import IMarkerInterfaces
class EditView(object):
"""Marker interface edit view.
"""
def __init__(self, context, request):
self.context = context
self.request = request
self.adapted = IMarkerInterfaces(context)
self.context_url = self.context.absolute_url()
def __call__(self, SAVE=None, add=(), remove=()):
if SAVE:
self.update(add, remove)
self.request.response.redirect(self.request.ACTUAL_URL)
return ''
return self.index()
def _getLinkToInterfaceDetailsView(self, interfaceName):
return (self.context_url + (
'/views-details.html?iface=%s&type=zope.publisher.'
'interfaces.browser.IBrowserRequest' % interfaceName))
def _getNameLinkDicts(self, interfaceNames):
return [dict(name=name,
link=self._getLinkToInterfaceDetailsView(name))
for name in interfaceNames]
def getAvailableInterfaceNames(self):
return self._getNameLinkDicts(
self.adapted.getAvailableInterfaceNames())
def getDirectlyProvidedNames(self):
return self._getNameLinkDicts(self.adapted.getDirectlyProvidedNames())
def getInterfaceNames(self):
return self._getNameLinkDicts(self.adapted.getInterfaceNames())
def update(self, add, remove):
# this could return errors
add = self.adapted.dottedToInterfaces(add)
remove = self.adapted.dottedToInterfaces(remove)
self.adapted.update(add=add, remove=remove)
##############################################################################
#
# Copyright (c) 2004, 2005 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Unit tests for marker interface views.
"""
def test_editview():
"""
Set everything up:
>>> from zope.component.testing import setUp, tearDown
>>> setUp()
>>> import AccessControl
>>> import Products.Five
>>> import Products.Five.utilities
>>> from Zope2.App import zcml
>>> zcml.load_config('meta.zcml', Products.Five)
>>> zcml.load_config('permissions.zcml', AccessControl)
>>> zcml.load_config('configure.zcml', Products.Five.utilities)
>>> from Products.Five.utilities.browser.marker import EditView
>>> from Products.Five.tests.testing.simplecontent import SimpleContent
>>> obj = SimpleContent('foo', 'Foo').__of__(self.folder)
Create an EditView:
>>> view = EditView(obj, {})
>>> view.context.aq_inner is obj
True
>>> view.request
{}
>>> view.getAvailableInterfaceNames()
[]
>>> view.getDirectlyProvidedNames()
[]
>>> view.getInterfaceNames()
[...ISimpleContent...]
Try to add a marker interface that doesn't exist:
>>> view.update(('__main__.IFooMarker',), ())
Traceback (most recent call last):
...
ComponentLookupError...
Now create the marker interface:
>>> from Products.Five.tests.testing.simplecontent import ISimpleContent
>>> class IFooMarker(ISimpleContent): pass
>>> from zope.component.interface import provideInterface
>>> provideInterface('', IFooMarker)
>>> view.getAvailableInterfaceNames()
[...IFooMarker...]
>>> view.getDirectlyProvidedNames()
[]
And try again to add it to the object:
>>> view.update(('__main__.IFooMarker',), ())
>>> view.getAvailableInterfaceNames()
[]
>>> view.getDirectlyProvidedNames()
[...IFooMarker...]
And remove it again:
>>> view.update((), ('__main__.IFooMarker',))
>>> view.getAvailableInterfaceNames()
[...IFooMarker...]
>>> view.getDirectlyProvidedNames()
[]
Finally tear down:
>>> tearDown()
"""
def test_suite():
from Testing.ZopeTestCase import ZopeDocTestSuite
return ZopeDocTestSuite()
<configure xmlns="http://namespaces.zope.org/zope">
<include package=".browser"/>
<adapter
for="*"
provides=".interfaces.IMarkerInterfaces"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment