[Checkins] SVN: grok/branches/grokcore.xxx/src/grok/ grokcore.view
now has a ViewSecurity grokker
Philipp von Weitershausen
philikon at philikon.de
Sat Jul 19 22:21:34 EDT 2008
Log message for revision 88631:
grokcore.view now has a ViewSecurity grokker
Changed:
U grok/branches/grokcore.xxx/src/grok/meta.py
U grok/branches/grokcore.xxx/src/grok/util.py
-=-
Modified: grok/branches/grokcore.xxx/src/grok/meta.py
===================================================================
--- grok/branches/grokcore.xxx/src/grok/meta.py 2008-07-20 02:21:06 UTC (rev 88630)
+++ grok/branches/grokcore.xxx/src/grok/meta.py 2008-07-20 02:21:34 UTC (rev 88631)
@@ -51,8 +51,6 @@
from grokcore.component.scan import determine_module_component
-import grokcore.view
-from grokcore.view.meta import ViewGrokkerBase
from grokcore.view.meta import PermissionGrokker
from grokcore.view.util import default_view_name
from grokcore.view.util import default_fallback_to_name
@@ -139,17 +137,6 @@
return True
-class ViewGrokker(ViewGrokkerBase):
- martian.component(grokcore.view.View)
-
- def protectName(self, config, factory, permission):
- config.action(
- discriminator=('protectName', factory, '__call__'),
- callable=make_checker,
- args=(factory, factory, permission),
- )
-
-
class JSONGrokker(martian.MethodGrokker):
martian.component(grok.JSON)
martian.directive(grok.context)
Modified: grok/branches/grokcore.xxx/src/grok/util.py
===================================================================
--- grok/branches/grokcore.xxx/src/grok/util.py 2008-07-20 02:21:06 UTC (rev 88630)
+++ grok/branches/grokcore.xxx/src/grok/util.py 2008-07-20 02:21:34 UTC (rev 88631)
@@ -17,41 +17,11 @@
import grok
import zope.location.location
-from zope import component
from zope import interface
+# XXX BBB
+from grokcore.view.util import make_checker, check_permission
-from zope.security.checker import NamesChecker, defineChecker
-from zope.security.interfaces import IPermission
-from martian.error import GrokError
-
-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 check_permission(factory, permission):
- """Check whether a permission is defined.
-
- If not, raise error for factory.
- """
- if component.queryUtility(IPermission,
- name=permission) is None:
- raise GrokError('Undefined permission %r in %r. Use '
- 'grok.Permission first.'
- % (permission, factory), factory)
-
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