Commit 7fa6b98a authored by Hanno Schlichting's avatar Hanno Schlichting

More Five avoidance

parent b96b2151
...@@ -152,9 +152,6 @@ class ObjectManager(CopyContainer, ...@@ -152,9 +152,6 @@ class ObjectManager(CopyContainer,
This class provides core behavior for collections of heterogeneous objects. This class provides core behavior for collections of heterogeneous objects.
""" """
# The claim to implement IContainer has been made during the Zope3
# integration project called Five but hasn't been completed in full.
implements(IObjectManager) implements(IObjectManager)
security = ClassSecurityInfo() security = ClassSecurityInfo()
......
...@@ -183,8 +183,7 @@ subscribe to them. ...@@ -183,8 +183,7 @@ subscribe to them.
so it doesn't have a location. so it doesn't have a location.
There are only a few basic use cases about what one wants to do with There are only a few basic use cases about what one wants to do with
respect to events (but you might want to read the full story in respect to events.
Five/tests/event.txt).
The first use case is the one where the object has to be aware of its The first use case is the one where the object has to be aware of its
path, like in the CoolDocument example above. path, like in the CoolDocument example above.
......
...@@ -117,7 +117,7 @@ def _registerClass(class_, meta_type, permission, addview, icon, global_): ...@@ -117,7 +117,7 @@ def _registerClass(class_, meta_type, permission, addview, icon, global_):
info = {'name': meta_type, info = {'name': meta_type,
'action': addview and ('+/%s' % addview) or '', 'action': addview and ('+/%s' % addview) or '',
'product': 'Five', 'product': 'OFS',
'permission': str(permission_obj.title), 'permission': str(permission_obj.title),
'visibility': global_ and 'Global' or None, 'visibility': global_ and 'Global' or None,
'interfaces': interfaces, 'interfaces': interfaces,
......
import unittest import unittest
from zope.component.testing import PlacelessSetup from zope.component.testing import PlacelessSetup
from zope.interface import implements
from AccessControl.Owned import EmergencyUserCannotOwn from AccessControl.Owned import EmergencyUserCannotOwn
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -11,13 +12,14 @@ from Acquisition import aq_base ...@@ -11,13 +12,14 @@ from Acquisition import aq_base
from Acquisition import Implicit from Acquisition import Implicit
from App.config import getConfiguration from App.config import getConfiguration
from logging import getLogger from logging import getLogger
from OFS.interfaces import IItem
from OFS.metaconfigure import setDeprecatedManageAddDelete from OFS.metaconfigure import setDeprecatedManageAddDelete
from OFS.ObjectManager import ObjectManager from OFS.ObjectManager import ObjectManager
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from Zope2.App import zcml from Zope2.App import zcml
from zExceptions import BadRequest from zExceptions import BadRequest
logger = getLogger('OFS.subscribers') logger = getLogger('OFS.subscribers')
class FauxRoot( Implicit ): class FauxRoot( Implicit ):
...@@ -61,12 +63,12 @@ class ItemForDeletion(SimpleItem): ...@@ -61,12 +63,12 @@ class ItemForDeletion(SimpleItem):
def manage_afterClone(self, item): def manage_afterClone(self, item):
pass pass
from zope.interface import implements
from OFS.interfaces import IItem
class ObjectManagerWithIItem(ObjectManager): class ObjectManagerWithIItem(ObjectManager):
"""The event subscribers work on IItem.""" """The event subscribers work on IItem."""
implements(IItem) implements(IItem)
class ObjectManagerTests(PlacelessSetup, unittest.TestCase): class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -92,11 +94,13 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase): ...@@ -92,11 +94,13 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
def _makeOne( self, *args, **kw ): def _makeOne( self, *args, **kw ):
return self._getTargetClass()( *args, **kw ).__of__( FauxRoot() ) return self._getTargetClass()( *args, **kw ).__of__( FauxRoot() )
def test_z3interfaces(self): def test_interfaces(self):
from OFS.interfaces import IObjectManager from OFS.interfaces import IObjectManager
from OFS.ObjectManager import ObjectManager from OFS.ObjectManager import ObjectManager
from zope.container.interfaces import IContainer
from zope.interface.verify import verifyClass from zope.interface.verify import verifyClass
verifyClass(IContainer, ObjectManager)
verifyClass(IObjectManager, ObjectManager) verifyClass(IObjectManager, ObjectManager)
def test_setObject_set_owner_with_no_user( self ): def test_setObject_set_owner_with_no_user( self ):
......
...@@ -186,8 +186,7 @@ class TestTraverse( unittest.TestCase ): ...@@ -186,8 +186,7 @@ class TestTraverse( unittest.TestCase ):
class BoboTraversableWithAcquisition(SimpleItem): class BoboTraversableWithAcquisition(SimpleItem):
""" A BoboTraversable which may use acquisition to find objects. """ A BoboTraversable which may use acquisition to find objects.
This is similar to how the __bobo_traverse__ added by Five This is similar to how the __bobo_traverse__ behaves).
behaves).
""" """
def __bobo_traverse__(self, request, name): def __bobo_traverse__(self, request, name):
...@@ -409,9 +408,8 @@ class SimpleClass(object): ...@@ -409,9 +408,8 @@ class SimpleClass(object):
def test_traversable(): def test_traversable():
""" """
Test the behaviour of unrestrictedTraverse and views. The tests are Test the behaviour of unrestrictedTraverse and views. The tests don't
copies from Five.browser.tests.test_traversable, but instead of use publishing but do unrestrictedTraverse instead.
publishing they do unrestrictedTraverse.
>>> import Products.Five >>> import Products.Five
>>> from Zope2.App import zcml >>> from Zope2.App import zcml
...@@ -433,9 +431,9 @@ def test_traversable(): ...@@ -433,9 +431,9 @@ def test_traversable():
... self.folder.testoid.unrestrictedTraverse('doesntexist') ... self.folder.testoid.unrestrictedTraverse('doesntexist')
... except NotFound: ... except NotFound:
... pass ... pass
Now let's take class which already has a __bobo_traverse__ method. Now let's take class which already has a __bobo_traverse__ method.
Five should correctly use that as a fallback. We should correctly use that as a fallback.
>>> configure_zcml = ''' >>> configure_zcml = '''
... <configure xmlns="http://namespaces.zope.org/zope" ... <configure xmlns="http://namespaces.zope.org/zope"
...@@ -527,7 +525,7 @@ def test_traversable(): ...@@ -527,7 +525,7 @@ def test_traversable():
Without a __bobo_traverse__ method this would have returned the attribute Without a __bobo_traverse__ method this would have returned the attribute
value 'This is an attribute'. Let's make sure the same thing happens for value 'This is an attribute'. Let's make sure the same thing happens for
an object that has been marked traversable by Five: an object that has been marked traversable:
>>> self.folder.fancy.an_attribute = 'This is an attribute' >>> self.folder.fancy.an_attribute = 'This is an attribute'
>>> self.folder.fancy.unrestrictedTraverse( >>> self.folder.fancy.unrestrictedTraverse(
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE. # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
"""Test events triggered by Five """Test events
$Id$ $Id$
""" """
......
...@@ -62,7 +62,7 @@ def test_registerClass(): ...@@ -62,7 +62,7 @@ def test_registerClass():
... if info['name'] == 'Foo Type': ... if info['name'] == 'Foo Type':
... break ... break
>>> info['product'] >>> info['product']
'Five' 'OFS'
>>> info['permission'] >>> info['permission']
'Add Foo' 'Add Foo'
>>> ISimpleContent in info['interfaces'] >>> ISimpleContent in info['interfaces']
...@@ -113,7 +113,7 @@ def test_registerClass(): ...@@ -113,7 +113,7 @@ def test_registerClass():
... if info['name'] == 'Bar Type': ... if info['name'] == 'Bar Type':
... break ... break
>>> info['product'] >>> info['product']
'Five' 'OFS'
>>> info['permission'] >>> info['permission']
'Add Bar' 'Add Bar'
>>> ISimpleContent in info['interfaces'] >>> ISimpleContent in info['interfaces']
......
...@@ -604,19 +604,19 @@ class HTTPRequestTests(unittest.TestCase): ...@@ -604,19 +604,19 @@ class HTTPRequestTests(unittest.TestCase):
self.assertEquals(req.cookies['hmm'], '') self.assertEquals(req.cookies['hmm'], '')
self.assertEquals(req.cookies['baz'], 'gee') self.assertEquals(req.cookies['baz'], 'gee')
# Unquoted multi-space cookies # Unquoted multi-space cookies
env['HTTP_COOKIE'] = 'single=cookie data; ' \ env['HTTP_COOKIE'] = 'single=cookie data; ' \
'quoted="cookie data with unquoted spaces"; ' \ 'quoted="cookie data with unquoted spaces"; ' \
'multi=cookie data with unquoted spaces; ' \ 'multi=cookie data with unquoted spaces; ' \
'multi2=cookie data with unquoted spaces' 'multi2=cookie data with unquoted spaces'
req = self._makeOne(environ=env) req = self._makeOne(environ=env)
self.assertEquals(req.cookies['single'], 'cookie data') self.assertEquals(req.cookies['single'], 'cookie data')
self.assertEquals(req.cookies['quoted'], self.assertEquals(req.cookies['quoted'],
'cookie data with unquoted spaces') 'cookie data with unquoted spaces')
self.assertEquals(req.cookies['multi'], self.assertEquals(req.cookies['multi'],
'cookie data with unquoted spaces') 'cookie data with unquoted spaces')
self.assertEquals(req.cookies['multi2'], self.assertEquals(req.cookies['multi2'],
'cookie data with unquoted spaces') 'cookie data with unquoted spaces')
...@@ -719,6 +719,14 @@ class HTTPRequestTests(unittest.TestCase): ...@@ -719,6 +719,14 @@ class HTTPRequestTests(unittest.TestCase):
request['debug'] = '2' request['debug'] = '2'
self.assertEqual(request.debug, '2') self.assertEqual(request.debug, '2')
def test_interfaces(self):
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.interface.verify import verifyClass
klass = self._getTargetClass()
# TODO
# verifyClass(IBrowserRequest, klass)
def test_locale_property_accessor(self): def test_locale_property_accessor(self):
from zope.component import provideAdapter from zope.component import provideAdapter
from zope.publisher.browser import BrowserLanguages from zope.publisher.browser import BrowserLanguages
...@@ -751,7 +759,6 @@ class HTTPRequestTests(unittest.TestCase): ...@@ -751,7 +759,6 @@ class HTTPRequestTests(unittest.TestCase):
from zope.publisher.browser import BrowserLanguages from zope.publisher.browser import BrowserLanguages
from zope.publisher.interfaces.http import IHTTPRequest from zope.publisher.interfaces.http import IHTTPRequest
from zope.i18n.interfaces import IUserPreferredLanguages from zope.i18n.interfaces import IUserPreferredLanguages
from zope.i18n.interfaces.locales import ILocale
provideAdapter(BrowserLanguages, [IHTTPRequest], provideAdapter(BrowserLanguages, [IHTTPRequest],
IUserPreferredLanguages) IUserPreferredLanguages)
...@@ -844,7 +851,7 @@ class HTTPRequestTests(unittest.TestCase): ...@@ -844,7 +851,7 @@ class HTTPRequestTests(unittest.TestCase):
request = self._makeOne(environ=env) request = self._makeOne(environ=env)
self.assertEqual(request.method, 'GET') self.assertEqual(request.method, 'GET')
def test_method_GET(self): def test_method_POST(self):
env = {'REQUEST_METHOD': 'POST'} env = {'REQUEST_METHOD': 'POST'}
request = self._makeOne(environ=env) request = self._makeOne(environ=env)
self.assertEqual(request.method, 'POST') self.assertEqual(request.method, 'POST')
......
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