[Checkins] SVN: grok/trunk/ Grok Views offer the ILocation interface, but were, in fact, failing

Brandon Rhodes brandon at rhodesmill.org
Sun Sep 23 07:49:55 EDT 2007


Log message for revision 79847:
  Grok Views offer the ILocation interface, but were, in fact, failing
  to offer Zope a meaningful __name__.  They tried to work around this
  flaw by registering a custom AbsoluteURL implementation on themselves.
  I have removed this adapter, in favor of having each View instance set
  its own __name__ correctly from class data upon instantiation.
  

Changed:
  U   grok/trunk/CHANGES.txt
  U   grok/trunk/src/grok/components.py
  U   grok/trunk/src/grok/configure.zcml

-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt	2007-09-23 09:10:29 UTC (rev 79846)
+++ grok/trunk/CHANGES.txt	2007-09-23 11:49:54 UTC (rev 79847)
@@ -27,6 +27,9 @@
 
 * `handle...` is not a special function name any more.
 
+* Views no longer need a custom AbsoluteURL to determine their URL,
+  since each instance now properly gets a __name__ attribute.
+
 Restructuring
 -------------
 

Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py	2007-09-23 09:10:29 UTC (rev 79846)
+++ grok/trunk/src/grok/components.py	2007-09-23 11:49:54 UTC (rev 79847)
@@ -23,23 +23,16 @@
 
 from zope import component
 from zope import interface
-from zope import schema
-from zope import event
 from zope.interface.common import idatetime
-from zope.lifecycleevent import ObjectModifiedEvent
 from zope.security.permission import Permission
 from zope.app.securitypolicy.role import Role
 from zope.publisher.browser import BrowserPage
 from zope.publisher.interfaces import NotFound
 from zope.publisher.interfaces.browser import (IBrowserPublisher,
-                                               IDefaultBrowserLayer,
                                                IBrowserRequest)
 from zope.publisher.publish import mapply
 from zope.pagetemplate import pagetemplate, pagetemplatefile
 from zope.formlib import form
-from zope.traversing.browser.interfaces import IAbsoluteURL
-from zope.traversing.browser.absoluteurl import AbsoluteURL
-from zope.traversing.browser.absoluteurl import _safe as SAFE_URL_CHARACTERS
 from zope.annotation.interfaces import IAttributeAnnotatable
 
 from zope.app.pagetemplate.engine import TrustedAppPT
@@ -105,6 +98,7 @@
 
     def __init__(self, context, request):
         super(View, self).__init__(context, request)
+        self.__name__ = self.__view_name__
         self.static = component.queryAdapter(
             self.request,
             interface.Interface,
@@ -179,14 +173,6 @@
         source.send(message, type)
 
 
-class GrokViewAbsoluteURL(AbsoluteURL):
-
-    def _getContextName(self, context):
-        return getattr(context, '__view_name__', None)
-    # XXX breadcrumbs method on AbsoluteURL breaks as it does not use
-    # _getContextName to get to the name of the view. What does breadcrumbs do?
-
-
 class XMLRPC(object):
     pass
 

Modified: grok/trunk/src/grok/configure.zcml
===================================================================
--- grok/trunk/src/grok/configure.zcml	2007-09-23 09:10:29 UTC (rev 79846)
+++ grok/trunk/src/grok/configure.zcml	2007-09-23 11:49:54 UTC (rev 79847)
@@ -28,28 +28,6 @@
   <securityPolicy
       component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
 
-  <!-- we register special IAbsoluteURL views on grok views so that
-       can have them inspect __view_name__ instead of __name__.  
-       __name__ is already used as the class name, and overriding it
-       may make error messages more confusing.  -->
-
-  <view
-      for=".interfaces.IGrokView"
-      name="absolute_url"
-      factory=".components.GrokViewAbsoluteURL"
-      type="zope.publisher.interfaces.http.IHTTPRequest"
-      permission="zope.Public"
-      allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
-      />
-
-  <view
-      for=".interfaces.IGrokView"
-      factory=".components.GrokViewAbsoluteURL"
-      type="zope.publisher.interfaces.http.IHTTPRequest"
-      permission="zope.Public"
-      provides="zope.traversing.browser.interfaces.IAbsoluteURL"
-      />
-
   <!-- this overrides Zope 3's publication factories because they have
        the same name; we also need to change the priority because of
        the ZCML discriminator -->



More information about the Checkins mailing list