[Checkins] SVN: grok/branches/grokcore.xxx/src/grok/ 'staticdir' ftests moved to grokcore.view.

Philipp von Weitershausen philikon at philikon.de
Tue Jul 22 14:56:42 EDT 2008


Log message for revision 88725:
  'staticdir' ftests moved to grokcore.view.
  
  The make_checker helper was removed in grokcore.view as well, so let's bring it
  back in grok, at least temporarily.
  

Changed:
  D   grok/branches/grokcore.xxx/src/grok/ftests/staticdir/
  U   grok/branches/grokcore.xxx/src/grok/ftests/test_grok_functional.py
  U   grok/branches/grokcore.xxx/src/grok/util.py

-=-
Modified: grok/branches/grokcore.xxx/src/grok/ftests/test_grok_functional.py
===================================================================
--- grok/branches/grokcore.xxx/src/grok/ftests/test_grok_functional.py	2008-07-22 18:49:07 UTC (rev 88724)
+++ grok/branches/grokcore.xxx/src/grok/ftests/test_grok_functional.py	2008-07-22 18:56:41 UTC (rev 88725)
@@ -70,8 +70,8 @@
 
 def test_suite():
     suite = unittest.TestSuite()
-    for name in ['staticdir', 'xmlrpc', 'traversal', 'form', 'url',
-                 'security', 'utility', 'catalog', 'site', 'rest', 'viewlet']:
+    for name in ['xmlrpc', 'traversal', 'form', 'url', 'security',
+                 'utility', 'catalog', 'site', 'rest', 'viewlet']:
         suite.addTest(suiteFromPackage(name))
     return suite
 

Modified: grok/branches/grokcore.xxx/src/grok/util.py
===================================================================
--- grok/branches/grokcore.xxx/src/grok/util.py	2008-07-22 18:49:07 UTC (rev 88724)
+++ grok/branches/grokcore.xxx/src/grok/util.py	2008-07-22 18:56:41 UTC (rev 88725)
@@ -13,15 +13,29 @@
 ##############################################################################
 """Grok utility functions.
 """
-
-
 import grok
 import zope.location.location
 from zope import interface
 # XXX BBB
-from grokcore.view.util import make_checker, check_permission
+from grokcore.view.util import check_permission
+from zope.security.checker import NamesChecker, defineChecker
 
+def make_checker(factory, view_factory, permission, method_names=None):
+    """Make a checker for a view_factory associated with factory.
 
+    These could be one and the same for normal views, or different
+    in case we make method-based views such as for JSON and XMLRPC.
+    """
+    if method_names is None:
+        method_names = ['__call__']
+    if permission is not None:
+        check_permission(factory, permission)
+    if permission is None or permission == 'zope.Public':
+        checker = NamesChecker(method_names)
+    else:
+        checker = NamesChecker(method_names, permission)
+    defineChecker(view_factory, checker)
+
 def safely_locate_maybe(obj, parent, name):
     """Set an object's __parent__ (and __name__) if the object's
     __parent__ attribute doesn't exist yet or is None.



More information about the Checkins mailing list