[Zope3-checkins] CVS: Zope3/src/zope/app/security/tests - test_protectclass.py:1.5

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Aug 15 21:45:09 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/security/tests
In directory cvs.zope.org:/tmp/cvs-serv20171/app/security/tests

Modified Files:
	test_protectclass.py 
Log Message:
Merging dreamcatcher's TTW Schema branch:

1. Fixed Bug in adding that would cause infinite loops when the menu items
   action was not a valif view or factory id.

2. Extended adding to support more complex views. Until now we only 
   supported constructions like "+/AddView=id". Now you are able to say
   "+/AddView/More=id", which means that more information can be carried 
   in the URL. This can be used in many ways, including multi-page adding
   wizards. In my case I needed it to pass in the type of the TTW Schema-
   based Content Component.

3. Added Local Menus. This was a pain in the butt, but I think I got a 
   fairly nice model, where you can create local Menu Services, and Menus
   are simply named utilities. When active they are menus in the menu 
   service. This is very similar to the local interface service and TTW 
   Schema. 

4. Made some modifications to TTW Schema, cleaned up the code and moved
   the browser code and interfaces to the places they belong.

5. Added a Content Component Definition utility component, which takes a
   Schema and creates a content component for it, including permission
   settings and a menu entry. Currently the menu entry is always made to
   a local 'add_content' menu. I will change this and make it actually a
   screen, where the menu and title of the menu item can be chosen by the
   developer. Mmmh, should I add a factory for the definition as well, so
   that the content component is also available via python?

6. Added a Content Component Instance component that represents an 
   instance od a Content Component Definition. You will never directly 
   encounter this component, since it is automatically used by the adding
   code of the Content Component Definition.

7. Cleanups by both dreamcatcher and myself.

That's it. For more details see the branch checkin messages. I now consider
the dreamcatcher-ttwschema-branch closed.


=== Zope3/src/zope/app/security/tests/test_protectclass.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/security/tests/test_protectclass.py:1.4	Sat Jun  7 01:46:06 2003
+++ Zope3/src/zope/app/security/tests/test_protectclass.py	Fri Aug 15 20:44:03 2003
@@ -63,6 +63,16 @@
         self.assertEqual(checker.permission_id('m2'), (m2P or None))
         self.assertEqual(checker.permission_id('m3'), (m3P or None))
 
+    def assertSetattrState(self, m1P=NOTSET, m2P=NOTSET, m3P=NOTSET):
+        "Verify that class, instance, and methods have expected permissions."
+
+        from zope.security.checker import selectChecker
+
+        checker = selectChecker(TestModule.test_instance)
+        self.assertEqual(checker.setattr_permission_id('m1'), (m1P or None))
+        self.assertEqual(checker.setattr_permission_id('m2'), (m2P or None))
+        self.assertEqual(checker.setattr_permission_id('m3'), (m3P or None))
+
     # "testSimple*" exercises tags that do NOT have children.  This mode
     # inherently sets the instances as well as the class attributes.
 
@@ -74,9 +84,12 @@
     def testLikeUntoOnly(self):
         protectName(TestModule.test_base, 'm1', P1)
         protectName(TestModule.test_base, 'm2', P1)
+        protectSetAttribute(TestModule.test_base, 'm1', P1)
+        protectSetAttribute(TestModule.test_base, 'm2', P1)
         protectLikeUnto(TestModule.test_class, TestModule.test_base)
         # m1 and m2 are in the interface, so should be set, and m3 should not:
         self.assertState(m1P=P1, m2P=P1)
+        self.assertSetattrState(m1P=P1, m2P=P1)
 
     def assertSetattrState(self, m1P=NOTSET, m2P=NOTSET, m3P=NOTSET):
         "Verify that class, instance, and methods have expected permissions."
@@ -96,11 +109,16 @@
     def testLikeUntoAsDefault(self):
         protectName(TestModule.test_base, 'm1', P1)
         protectName(TestModule.test_base, 'm2', P1)
+        protectSetAttribute(TestModule.test_base, 'm1', P1)
+        protectSetAttribute(TestModule.test_base, 'm2', P1)
         protectLikeUnto(TestModule.test_class, TestModule.test_base)
         protectName(TestModule.test_class, 'm2', P2)
         protectName(TestModule.test_class, 'm3', P2)
+        protectSetAttribute(TestModule.test_class, 'm2', P2)
+        protectSetAttribute(TestModule.test_class, 'm3', P2)
         # m1 and m2 are in the interface, so should be set, and m3 should not:
         self.assertState(m1P=P1, m2P=P2, m3P=P2)
+        self.assertSetattrState(m1P=P1, m2P=P2, m3P=P2)
 
 def test_suite():
     loader=unittest.TestLoader()




More information about the Zope3-Checkins mailing list