[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/Five/ Merge r40372 from 2.9 branch: Updated to Five 1.3b4

Florent Guillaume fg at nuxeo.com
Fri Nov 25 16:24:07 EST 2005


Log message for revision 40373:
  Merge r40372 from 2.9 branch: Updated to Five 1.3b4

Changed:
  U   Zope/trunk/lib/python/Products/Five/CHANGES.txt
  U   Zope/trunk/lib/python/Products/Five/__init__.py
  U   Zope/trunk/lib/python/Products/Five/tests/event.txt
  U   Zope/trunk/lib/python/Products/Five/tests/test_security.py
  U   Zope/trunk/lib/python/Products/Five/version.txt

-=-
Modified: Zope/trunk/lib/python/Products/Five/CHANGES.txt
===================================================================
--- Zope/trunk/lib/python/Products/Five/CHANGES.txt	2005-11-25 21:21:52 UTC (rev 40372)
+++ Zope/trunk/lib/python/Products/Five/CHANGES.txt	2005-11-25 21:24:07 UTC (rev 40373)
@@ -2,6 +2,16 @@
 Five Changes
 ============
 
+Five 1.3b4 (2005-11-25)
+=======================
+
+Restructuring
+-------------
+
+* Cleaned up security test.
+
+* Made Five send a ContainerModifiedEvent when appropriate.
+
 Five 1.3b3 (2005-11-19)
 =======================
 

Modified: Zope/trunk/lib/python/Products/Five/__init__.py
===================================================================
--- Zope/trunk/lib/python/Products/Five/__init__.py	2005-11-25 21:21:52 UTC (rev 40372)
+++ Zope/trunk/lib/python/Products/Five/__init__.py	2005-11-25 21:24:07 UTC (rev 40373)
@@ -13,13 +13,17 @@
 ##############################################################################
 """Initialize the Five product
 
-$Id: __init__.py 12884 2005-05-30 13:10:41Z philikon $
+$Id: __init__.py 20254 2005-11-25 18:45:08Z efge $
 """
 import Acquisition
 from Globals import INSTANCE_HOME
 
+import monkey # BBB: goes away when Zope 3.2 >= r40368 is stiched in
 import zcml
 
+# trigger monkey patches
+monkey.monkeyPatch()
+
 # public API provided by Five
 # usage: from Products.Five import <something>
 from browser import BrowserView

Modified: Zope/trunk/lib/python/Products/Five/tests/event.txt
===================================================================
--- Zope/trunk/lib/python/Products/Five/tests/event.txt	2005-11-25 21:21:52 UTC (rev 40372)
+++ Zope/trunk/lib/python/Products/Five/tests/event.txt	2005-11-25 21:24:07 UTC (rev 40373)
@@ -105,6 +105,7 @@
   ObjectWillBeAddedEvent sub
   ObjectAddedEvent sub
   old manage_afterAdd sub sub folder
+  ContainerModifiedEvent folder
   'sub'
   >>> sub = folder.sub
   >>> ob = MyContent('dog')
@@ -112,6 +113,7 @@
   ObjectWillBeAddedEvent dog
   ObjectAddedEvent dog
   old manage_afterAdd dog dog sub
+  ContainerModifiedEvent sub
   'dog'
 
 And when we rename the subfolder, manage_beforeDelete is also called
@@ -126,6 +128,7 @@
   old manage_afterAdd marine marine folder
   ObjectMovedEvent dog
   old manage_afterAdd dog marine folder
+  ContainerModifiedEvent folder
 
 Same thing for clone::
 
@@ -137,6 +140,7 @@
   old manage_afterAdd tank tank folder
   ObjectAddedEvent dog
   old manage_afterAdd dog tank folder
+  ContainerModifiedEvent folder
   ObjectClonedEvent tank
   old manage_afterClone tank tank
   ObjectClonedEvent dog
@@ -161,6 +165,7 @@
   ObjectWillBeAddedEvent lassie
   ObjectAddedEvent lassie
   old manage_afterAdd lassie lassie folder
+  ContainerModifiedEvent folder
   'lassie'
 
 And when we delete the object, manage_beforeDelete is also called and
@@ -170,6 +175,7 @@
   ObjectWillBeRemovedEvent lassie
   old manage_beforeDelete lassie lassie folder
   ObjectRemovedEvent lassie
+  ContainerModifiedEvent folder
 
 The old behavior happens for a move or a copy, with events too.
 For a move::
@@ -179,6 +185,7 @@
   ObjectWillBeAddedEvent blueberry
   ObjectAddedEvent blueberry
   old manage_afterAdd blueberry blueberry folder
+  ContainerModifiedEvent folder
   'blueberry'
   >>> cp = folder.manage_cutObjects('blueberry')
   >>> folder.manage_pasteObjects(cp)
@@ -186,6 +193,7 @@
   old manage_beforeDelete blueberry blueberry folder
   ObjectMovedEvent blueberry
   old manage_afterAdd blueberry blueberry folder
+  ContainerModifiedEvent folder
   [{'new_id': 'blueberry', 'id': 'blueberry'}]
 
 Old behavior with events for a copy::
@@ -196,6 +204,7 @@
   ObjectWillBeAddedEvent copy_of_blueberry
   ObjectAddedEvent copy_of_blueberry
   old manage_afterAdd copy_of_blueberry copy_of_blueberry folder
+  ContainerModifiedEvent folder
   ObjectClonedEvent copy_of_blueberry
   old manage_afterClone copy_of_blueberry copy_of_blueberry
   [{'new_id': 'copy_of_blueberry', 'id': 'blueberry'}]
@@ -207,6 +216,7 @@
   old manage_beforeDelete copy_of_blueberry copy_of_blueberry folder
   ObjectMovedEvent myrtille
   old manage_afterAdd myrtille myrtille folder
+  ContainerModifiedEvent folder
 
 Old behavior with events for a clone::
 
@@ -215,6 +225,7 @@
   ObjectWillBeAddedEvent strawberry
   ObjectAddedEvent strawberry
   old manage_afterAdd strawberry strawberry folder
+  ContainerModifiedEvent folder
   ObjectClonedEvent strawberry
   old manage_afterClone strawberry strawberry
   >>> res.getId()
@@ -227,12 +238,14 @@
   ObjectWillBeAddedEvent luckyluke
   ObjectAddedEvent luckyluke
   old manage_afterAdd luckyluke luckyluke btfolder
+  ContainerModifiedEvent btfolder
   'luckyluke'
 
   >>> btfolder.manage_delObjects('luckyluke')
   ObjectWillBeRemovedEvent luckyluke
   old manage_beforeDelete luckyluke luckyluke btfolder
   ObjectRemovedEvent luckyluke
+  ContainerModifiedEvent btfolder
 
 Here is what happens for a tree of objects. Let's create a simple one::
 
@@ -241,6 +254,7 @@
   ObjectWillBeAddedEvent subfolder
   ObjectAddedEvent subfolder
   old manage_afterAdd subfolder subfolder folder
+  ContainerModifiedEvent folder
   'subfolder'
   >>> subfolder = folder.subfolder
   >>> ob = MyContent('donald')
@@ -248,6 +262,7 @@
   ObjectWillBeAddedEvent donald
   ObjectAddedEvent donald
   old manage_afterAdd donald donald subfolder
+  ContainerModifiedEvent subfolder
   'donald'
 
 Renaming a tree of objects. Note that manage_beforeDelete is called
@@ -262,6 +277,7 @@
   old manage_afterAdd pluto pluto folder
   ObjectMovedEvent donald
   old manage_afterAdd donald pluto folder
+  ContainerModifiedEvent folder
 
 Cloning a tree of objects::
 
@@ -273,6 +289,7 @@
   old manage_afterAdd mickey mickey folder
   ObjectAddedEvent donald
   old manage_afterAdd donald mickey folder
+  ContainerModifiedEvent folder
   ObjectClonedEvent mickey
   old manage_afterClone mickey mickey
   ObjectClonedEvent donald
@@ -290,9 +307,10 @@
   >>> app = MyApp('')
   >>> root['app'] = app
   >>> folder = MyNewFolder('folder')
-  >>> app._setObject('folder', folder)
+  >>> app._setObject('folder', folder) # doctest: +NORMALIZE_WHITESPACE
   ObjectWillBeAddedEvent folder
   ObjectAddedEvent folder
+  ContainerModifiedEvent
   'folder'
   >>> folder = app.folder
 
@@ -300,10 +318,12 @@
   >>> folder._setObject('dogbert', ob)
   ObjectWillBeAddedEvent dogbert
   ObjectAddedEvent dogbert
+  ContainerModifiedEvent folder
   'dogbert'
   >>> folder.manage_delObjects('dogbert')
   ObjectWillBeRemovedEvent dogbert
   ObjectRemovedEvent dogbert
+  ContainerModifiedEvent folder
 
 Now move::
 
@@ -311,11 +331,13 @@
   >>> folder._setObject('dilbert', ob)
   ObjectWillBeAddedEvent dilbert
   ObjectAddedEvent dilbert
+  ContainerModifiedEvent folder
   'dilbert'
   >>> cp = folder.manage_cutObjects('dilbert')
   >>> folder.manage_pasteObjects(cp)
   ObjectWillBeMovedEvent dilbert
   ObjectMovedEvent dilbert
+  ContainerModifiedEvent folder
   [{'new_id': 'dilbert', 'id': 'dilbert'}]
 
 And copy::
@@ -325,6 +347,7 @@
   ObjectCopiedEvent copy_of_dilbert
   ObjectWillBeAddedEvent copy_of_dilbert
   ObjectAddedEvent copy_of_dilbert
+  ContainerModifiedEvent folder
   ObjectClonedEvent copy_of_dilbert
   [{'new_id': 'copy_of_dilbert', 'id': 'dilbert'}]
 
@@ -333,6 +356,7 @@
   >>> folder.manage_renameObject('copy_of_dilbert', 'wally')
   ObjectWillBeMovedEvent copy_of_dilbert
   ObjectMovedEvent wally
+  ContainerModifiedEvent folder
 
 Or copy using manage_clone::
 
@@ -340,6 +364,7 @@
   ObjectCopiedEvent phb
   ObjectWillBeAddedEvent phb
   ObjectAddedEvent phb
+  ContainerModifiedEvent folder
   ObjectClonedEvent phb
   >>> res.getId()
   'phb'
@@ -350,13 +375,16 @@
   >>> btfolder._setObject('alice', ob)
   ObjectWillBeAddedEvent alice
   ObjectAddedEvent alice
+  ContainerModifiedEvent btfolder
   'alice'
   >>> btfolder.manage_renameObject('alice', 'rabbit')
   ObjectWillBeMovedEvent alice
   ObjectMovedEvent rabbit
+  ContainerModifiedEvent btfolder
   >>> btfolder.manage_delObjects('rabbit')
   ObjectWillBeRemovedEvent rabbit
   ObjectRemovedEvent rabbit
+  ContainerModifiedEvent btfolder
 
 Now for a tree of objects. Let's create a simple one::
 
@@ -364,12 +392,14 @@
   >>> folder._setObject('subfolder', subfolder)
   ObjectWillBeAddedEvent subfolder
   ObjectAddedEvent subfolder
+  ContainerModifiedEvent folder
   'subfolder'
   >>> subfolder = folder.subfolder
   >>> ob = MyNewContent('mel')
   >>> subfolder._setObject('mel', ob)
   ObjectWillBeAddedEvent mel
   ObjectAddedEvent mel
+  ContainerModifiedEvent subfolder
   'mel'
 
 Renaming a tree of objects::
@@ -379,6 +409,7 @@
   ObjectWillBeMovedEvent mel
   ObjectMovedEvent firefly
   ObjectMovedEvent mel
+  ContainerModifiedEvent folder
 
 Cloning a tree of objects::
 
@@ -388,6 +419,7 @@
   ObjectWillBeAddedEvent mel
   ObjectAddedEvent serenity
   ObjectAddedEvent mel
+  ContainerModifiedEvent folder
   ObjectClonedEvent serenity
   ObjectClonedEvent mel
   >>> res.getId()
@@ -400,24 +432,35 @@
   ObjectWillBeAddedEvent ofolder
   ObjectAddedEvent ofolder
   old manage_afterAdd ofolder ofolder
+  ContainerModifiedEvent
   'ofolder'
   >>> ob1 = MyNewContent('ob1')
   >>> ofolder._setObject('ob1', ob1)
   ObjectWillBeAddedEvent ob1
   ObjectAddedEvent ob1
+  ContainerModifiedEvent ofolder
   'ob1'
   >>> ob2 = MyNewContent('ob2')
   >>> ofolder._setObject('ob2', ob2)
   ObjectWillBeAddedEvent ob2
   ObjectAddedEvent ob2
+  ContainerModifiedEvent ofolder
   'ob2'
   >>> ofolder.manage_renameObject('ob1', 'ob4')
   ObjectWillBeMovedEvent ob1
   ObjectMovedEvent ob4
+  ContainerModifiedEvent ofolder
   >>> ofolder.objectIds()
   ['ob4', 'ob2']
 
+When subobjects are reordered, an event about the container is sent::
 
+  >>> ofolder.moveObjectsUp('ob2')
+  ContainerModifiedEvent ofolder
+  1
+  >>> ofolder.objectIds()
+  ['ob2', 'ob4']
+
 Now cleanup::
 
   >>> import transaction

Modified: Zope/trunk/lib/python/Products/Five/tests/test_security.py
===================================================================
--- Zope/trunk/lib/python/Products/Five/tests/test_security.py	2005-11-25 21:21:52 UTC (rev 40372)
+++ Zope/trunk/lib/python/Products/Five/tests/test_security.py	2005-11-25 21:24:07 UTC (rev 40373)
@@ -95,38 +95,35 @@
 
     Now we look at the individual permissions:
 
-      >>> bar_roles1 = getattr(Dummy1, 'bar__roles__').__of__(Dummy1)
-      >>> bar_roles1.__of__(Dummy1)
+      >>> from AccessControl.ZopeSecurityPolicy import getRoles
+      >>> from AccessControl import ACCESS_PUBLIC
+      >>> from AccessControl import ACCESS_PRIVATE
+
+      >>> dummy1 = Dummy1()
+      >>> getRoles(dummy1, 'bar', dummy1.bar, ('Def',))
       ('Manager',)
 
-      >>> keg_roles1 = getattr(Dummy1, 'keg__roles__').__of__(Dummy1)
-      >>> keg_roles1.__of__(Dummy1)
+      >>> getRoles(dummy1, 'keg', dummy1.keg, ('Def',))
       ('Manager',)
 
-      >>> foo_roles1 = getattr(Dummy1, 'foo__roles__')
-      >>> foo_roles1 is None
+      >>> getRoles(dummy1, 'foo', dummy1.foo, ('Def',)) is ACCESS_PUBLIC
       True
 
-      >>> # XXX Not yet supported.
-      >>> # baz_roles1 = getattr(Dummy1, 'baz__roles__')
-      >>> # baz_roles1
-      ()
-        
-      >>> bar_roles2 = getattr(Dummy2, 'bar__roles__').__of__(Dummy2)
-      >>> bar_roles2.__of__(Dummy2)
+      #>>> getRoles(dummy1, 'baz', dummy1.baz, ('Def',)) is ACCESS_PRIVATE
+      #True XXX Not yet supported.
+
+      >>> dummy2 = Dummy2()
+      >>> getRoles(dummy2, 'bar', dummy2.bar, ('Def',))
       ('Manager',)
 
-      >>> keg_roles2 = getattr(Dummy2, 'keg__roles__').__of__(Dummy2)
-      >>> keg_roles2.__of__(Dummy2)
+      >>> getRoles(dummy2, 'keg', dummy2.keg, ('Def',))
       ('Manager',)
 
-      >>> foo_roles2 = getattr(Dummy2, 'foo__roles__')
-      >>> foo_roles2 is None
+      >>> getRoles(dummy2, 'foo', dummy2.foo, ('Def',)) is ACCESS_PUBLIC
       True
 
-      >>> baz_roles2 = getattr(Dummy2, 'baz__roles__')
-      >>> baz_roles2
-      ()
+      >>> getRoles(dummy2, 'baz', dummy2.baz, ('Def',)) is ACCESS_PRIVATE
+      True
 
     Before we end we should clean up after ourselves:
 

Modified: Zope/trunk/lib/python/Products/Five/version.txt
===================================================================
--- Zope/trunk/lib/python/Products/Five/version.txt	2005-11-25 21:21:52 UTC (rev 40372)
+++ Zope/trunk/lib/python/Products/Five/version.txt	2005-11-25 21:24:07 UTC (rev 40373)
@@ -1 +1 @@
-Five 1.3b3
+Five 1.3b4



More information about the Zope-Checkins mailing list