[Checkins] SVN: grok/trunk/ Undo the 'CodeView' thing.

Martijn Faassen faassen at startifact.com
Thu Sep 17 05:09:19 EDT 2009


Log message for revision 104191:
  Undo the 'CodeView' thing.
  

Changed:
  U   grok/trunk/CHANGES.txt
  U   grok/trunk/buildout.cfg
  U   grok/trunk/doc/groktut/completely_python_driven_views/src/sample/app.py
  U   grok/trunk/doc/groktut/setting_the_content_type/src/sample/app.py
  U   grok/trunk/doc/tutorial.rst
  U   grok/trunk/doc/upgrade.txt
  U   grok/trunk/grokwiki/src/grokwiki/wiki.py
  U   grok/trunk/setup.py
  U   grok/trunk/src/grok/__init__.py
  U   grok/trunk/src/grok/components.py
  U   grok/trunk/src/grok/ftests/catalog/addform.py
  U   grok/trunk/src/grok/ftests/publish/unauthorizednotreraised.py
  U   grok/trunk/src/grok/ftests/rest/rest_traverse.py
  U   grok/trunk/src/grok/ftests/security/grok_view.py
  U   grok/trunk/src/grok/ftests/security/handle_exception.py
  U   grok/trunk/src/grok/ftests/security/preserve_permissions.py
  U   grok/trunk/src/grok/ftests/security/roles.py
  U   grok/trunk/src/grok/ftests/traversal/containertraverse.py
  U   grok/trunk/src/grok/ftests/traversal/containertraverser.py
  U   grok/trunk/src/grok/ftests/traversal/items_before_views.py
  U   grok/trunk/src/grok/ftests/traversal/traversableattr.py
  U   grok/trunk/src/grok/ftests/url/application.py
  U   grok/trunk/src/grok/tests/baseclass/basedirective.py
  U   grok/trunk/src/grok/tests/container/container_model.py
  U   grok/trunk/src/grok/tests/viewlet/viewlet_references.py
  U   grok/trunk/versions.cfg

-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/CHANGES.txt	2009-09-17 09:09:18 UTC (rev 104191)
@@ -6,10 +6,19 @@
 
 See: :ref:`upgrade_notes_1.0b2` for special notes on upgrading to this release.
 
-* Bump versions of grokcore.formlib and grokcore.viewlet.
+* ``grokcore.view``, ``grokcore.viewlet`` and ``grokcore.formlib`` and
+  Grok itself have been updated to undo the ``View``/``CodeView``
+  split that we had temporarily introduced in the development versions
+  after Grok 1.0a4.  This means the behavior of ``grok.View`` is
+  unchanged from Grok 1.0a4. Nothing to see here!
 
-* Bump version of grokcore.security.
+* Changed the default permission to ``zope.View`` instead of
+  ``zope.Public``. This means a modification needs to be made to your
+  ``site.zcml`` if you're upgrading an existing Grok-based
+  project. See the upgrade notes for more information.
 
+  See also https://bugs.launchpad.net/grok/+bug/387332
+
 * Bump used zope.app.wsgi version (now: 3.4.2) to support
   product-configs in zope.conf files with paster. Fix
   https://bugs.launchpad.net/grok/+bug/220440
@@ -18,10 +27,6 @@
   now ``var/filestorage/`` and ``var/log/`` instead of ``parts/data/``
   and ``parts/log/``.
 
-* Bumped grokcore.view version: the ``View`` class is now split into
-  ``View`` (with a template) and ``CodeView`` (with just a render()
-  method).
-
 * Bump used `z3c.testsetup` version (now: 0.4). Fix
   https://bugs.launchpad.net/grok/+bug/395125
 
@@ -45,11 +50,8 @@
 * switched buildout to paster based template (like grokproject default)
   https://bugs.launchpad.net/grok/+bug/307197
 
-* changed interpreter name from 'python' to 'grokpy'
+* changed interpreter name from 'python' to 'grokpy'.
 
-* Changed the default permission to ``zope.View`` instead of
-  ``zope.Public``.  https://bugs.launchpad.net/grok/+bug/387332
-
 * Restructured the upgrade and change documentation so that they now
   get generated into separate files by Sphinx
 

Modified: grok/trunk/buildout.cfg
===================================================================
--- grok/trunk/buildout.cfg	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/buildout.cfg	2009-09-17 09:09:18 UTC (rev 104191)
@@ -1,6 +1,5 @@
 [buildout]
 extends = versions.cfg
-find-links = http://download.zope.org/distribution/
 parts =
     docs
     interpreter

Modified: grok/trunk/doc/groktut/completely_python_driven_views/src/sample/app.py
===================================================================
--- grok/trunk/doc/groktut/completely_python_driven_views/src/sample/app.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/doc/groktut/completely_python_driven_views/src/sample/app.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -3,6 +3,6 @@
 class Sample(grok.Application, grok.Container):
     pass
 
-class Index(grok.CodeView):
+class Index(grok.View):
     def render(self):
         return "ME GROK NO TEMPLATE"

Modified: grok/trunk/doc/groktut/setting_the_content_type/src/sample/app.py
===================================================================
--- grok/trunk/doc/groktut/setting_the_content_type/src/sample/app.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/doc/groktut/setting_the_content_type/src/sample/app.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -3,7 +3,7 @@
 class Sample(grok.Application, grok.Container):
     pass
 
-class Index(grok.CodeView):
+class Index(grok.View):
     def render(self):
         self.response.setHeader('Content-Type',
                                 'text/xml; charset=UTF-8')

Modified: grok/trunk/doc/tutorial.rst
===================================================================
--- grok/trunk/doc/tutorial.rst	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/doc/tutorial.rst	2009-09-17 09:09:18 UTC (rev 104191)
@@ -755,8 +755,7 @@
 
 Sometimes it is inconvenient to have to use a template at all. Perhaps
 we are not returning a HTML page at all, for instance. In this case, we
-can use a special ``grok.CodeView`` baseclass with a ``render`` method 
-on a view.
+can use the special ``render`` method on a view.
 
 Modify ``app.py`` so it reads like this:
 
@@ -764,15 +763,15 @@
   :literal:
 
 If you were to start up the server with an ``index.pt`` template still
-inside ``app_templates`` you would get a warning::
+inside ``app_templates`` you would get a an error::
 
-    Found the following unassociated template(s) when grokking
-    'sample.app': index.  Define view classes inheriting from
-    grok.View to enable the template(s).
+    GrokError: Multiple possible ways to render view <class
+    'sample.app.Index'>. It has both a 'render' method as well as an
+    associated template.
 
-Grok warns you here that it can find a template ``index`` even though
-there is no ``grok.View`` to associate it with. You can safely remove
-the ``index.pt`` file from the ``app_templates`` directory now.
+In the face of ambiguity Grok, like Python, refuses to guess. To
+resolve this error, remove ``index.pt`` from the ``app_templates``
+directory.
 
 Now take another look at our test application:
 

Modified: grok/trunk/doc/upgrade.txt
===================================================================
--- grok/trunk/doc/upgrade.txt	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/doc/upgrade.txt	2009-09-17 09:09:18 UTC (rev 104191)
@@ -16,13 +16,6 @@
 Upgrading to 1.0b2 (2009-09-15)
 -------------------------------
 
-* The ``View`` class (from either grokcore.view or grok itself) has
-  been split into ``View`` and ``CodeView``. ``CodeView`` is only for
-  use with a ``render`` method, and ``View`` is only for templates.
-
-  If you have a template: use ``View``.  If you have a render method:
-  you must subclass from ``CodeView`` instead of ``View`` from now on.
-
 * The default permission is now ``zope.View`` as a replacement for
   ``zope.Public``.  You need to add this permission as a default
   permission to all users (use ``zope.Anybody``). This requires a
@@ -126,6 +119,11 @@
   you can add it again however. We know that ``megrok.form`` for instance
   depends on a release that was only available in this repository.
 
+* Note: in 1.0b1 we used to have a split between ``View`` and
+  ``CodeView``.  This split got reverted. Grok's behavior is still the
+  same as in the 1.0a versions - views and the ``render`` method continue
+  to work as they did before.
+
 .. _upgrade_notes_1.0a1:
 
 Upgrading to 1.0b1 (2009-09-14)

Modified: grok/trunk/grokwiki/src/grokwiki/wiki.py
===================================================================
--- grok/trunk/grokwiki/src/grokwiki/wiki.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/grokwiki/src/grokwiki/wiki.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -20,11 +20,11 @@
 class Wiki(grok.Application, grok.Container):
     """This is Grok's sample wiki application."""
 
-class Index(grok.CodeView):
+class Index(grok.View):
     def render(self):
         self.redirect(self.url('home'))
 
-class Hello(grok.CodeView):
+class Hello(grok.View):
     grok.baseclass()
     
     def render(self):

Modified: grok/trunk/setup.py
===================================================================
--- grok/trunk/setup.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/setup.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -35,12 +35,12 @@
     include_package_data = True,
     zip_safe=False,
     install_requires=['setuptools',
-                      'martian >= 0.10',
-                      'grokcore.component >= 1.5',
-                      'grokcore.formlib',
+                      'martian >= 0.10, < 0.12',
+                      'grokcore.component >= 1.5, < 2.0',
+                      'grokcore.formlib >= 1.4',
                       'grokcore.security >= 1.1',
-                      'grokcore.view',
-                      'grokcore.viewlet',
+                      'grokcore.view >= 1.2.1',
+                      'grokcore.viewlet >= 1.3',
                       'simplejson',
                       'pytz',
                       'ZODB3',

Modified: grok/trunk/src/grok/__init__.py
===================================================================
--- grok/trunk/src/grok/__init__.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/__init__.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -71,7 +71,7 @@
     ObjectRemovedEvent,
     ContainerModifiedEvent)
 
-from grok.components import Model, View, CodeView
+from grok.components import Model, View
 from grok.components import XMLRPC, REST, JSON
 from grok.components import Traverser
 from grok.components import Container, OrderedContainer

Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/components.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -215,32 +215,7 @@
     """The base class for annotation classes in Grok applications."""
 
 
-class BaseView(object):
-    """ Base Class for helper methods"""
-    interface.implements(interfaces.IGrokView)
-
-    def application_url(self, name=None):
-        """Return the URL of the nearest enclosing `grok.Application`."""
-        obj = self.context
-        while obj is not None:
-            if isinstance(obj, Application):
-                return self.url(obj, name)
-            obj = obj.__parent__
-        raise ValueError("No application found.")
-
-    def flash(self, message, type='message'):
-        """Send a short message to the user."""
-        # XXX this has no tests or documentation, anywhere
-        source = component.getUtility(
-            z3c.flashmessage.interfaces.IMessageSource, name='session')
-        source.send(message, type)
-
-
-class CodeView(grokcore.view.CodeView, BaseView):
-    """The base class for views with just a render() method in grok apps"""
-
-
-class View(grokcore.view.View, BaseView):
+class View(grokcore.view.View):
     """The base class for views with templates in Grok applications.
 
     Each class that inherits from `grok.View` is designed to "render" a
@@ -310,9 +285,26 @@
     rendered under ``self.context``.
 
     """
+    interface.implements(interfaces.IGrokView)
 
+    def application_url(self, name=None):
+        """Return the URL of the nearest enclosing `grok.Application`."""
+        obj = self.context
+        while obj is not None:
+            if isinstance(obj, Application):
+                return self.url(obj, name)
+            obj = obj.__parent__
+        raise ValueError("No application found.")
 
+    def flash(self, message, type='message'):
+        """Send a short message to the user."""
+        # XXX this has no tests or documentation, anywhere
+        source = component.getUtility(
+            z3c.flashmessage.interfaces.IMessageSource, name='session')
+        source.send(message, type)
 
+
+
 class Form(grokcore.formlib.Form, View):
     """The base class for forms in Grok applications.
 

Modified: grok/trunk/src/grok/ftests/catalog/addform.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/addform.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/catalog/addform.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -53,14 +53,14 @@
 class Mammoth(grok.Model):
     grok.implements(IMammoth)
 
-class Index(grok.CodeView):
+class Index(grok.View):
     grok.context(Mammoth)
 
     def render(self):
         return 'Hi, my name is %s, and I\'m "%s"' % (self.context.name,
                                                      self.context.size)
 
-class Search(grok.CodeView):
+class Search(grok.View):
     grok.context(Zoo)
 
     def render(self):

Modified: grok/trunk/src/grok/ftests/publish/unauthorizednotreraised.py
===================================================================
--- grok/trunk/src/grok/ftests/publish/unauthorizednotreraised.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/publish/unauthorizednotreraised.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -29,7 +29,7 @@
 class App(grok.Application, grok.Container):
     pass
 
-class Index(grok.CodeView):
+class Index(grok.View):
     grok.require('grok.Manager')
     def render(self):
         return 'Hello from protected view'

Modified: grok/trunk/src/grok/ftests/rest/rest_traverse.py
===================================================================
--- grok/trunk/src/grok/ftests/rest/rest_traverse.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/rest/rest_traverse.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -67,7 +67,7 @@
             applySkin(self.request, LayerZ, grok.IRESTSkinType)
             return MyContent()
 
-class Index(grok.CodeView):
+class Index(grok.View):
     grok.context(MyApp)
     def render(self):
         return "The index view"

Modified: grok/trunk/src/grok/ftests/security/grok_view.py
===================================================================
--- grok/trunk/src/grok/ftests/security/grok_view.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/security/grok_view.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -23,6 +23,6 @@
 class App(grok.Application, grok.Container):
     pass
 
-class Index(grok.CodeView):
+class Index(grok.View):
     def render(self):
         return "Hello world"

Modified: grok/trunk/src/grok/ftests/security/handle_exception.py
===================================================================
--- grok/trunk/src/grok/ftests/security/handle_exception.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/security/handle_exception.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -23,7 +23,7 @@
     pass
 
 
-class Cave(grok.CodeView):
+class Cave(grok.View):
 
     grok.context(zope.interface.Interface)
 
@@ -33,7 +33,7 @@
         raise CaveWasRobbedError("EVERYTHING GONE! GROK ANGRY!")
 
 
-class CaveErrorView(grok.CodeView):
+class CaveErrorView(grok.View):
 
     grok.context(CaveWasRobbedError)
     grok.name("index.html")

Modified: grok/trunk/src/grok/ftests/security/preserve_permissions.py
===================================================================
--- grok/trunk/src/grok/ftests/security/preserve_permissions.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/security/preserve_permissions.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -98,11 +98,11 @@
 class App(grok.Application, grok.Container):
     pass
 
-class Index(grok.CodeView):
+class Index(grok.View):
     def render(self):
         return 'Moo!'
 
-class Manage(grok.CodeView):
+class Manage(grok.View):
     grok.require('app.Manage')
     def render(self):
         return 'Woo!'

Modified: grok/trunk/src/grok/ftests/security/roles.py
===================================================================
--- grok/trunk/src/grok/ftests/security/roles.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/security/roles.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -64,7 +64,7 @@
     grok.permissions(
         'paint.ViewPainting', 'paint.EditPainting', 'paint.ErasePainting')
 
-class CavePainting(grok.CodeView):
+class CavePainting(grok.View):
 
     grok.context(zope.interface.Interface)
     grok.require(ViewPermission)
@@ -72,7 +72,7 @@
     def render(self):
         return 'What a beautiful painting.'
 
-class EditCavePainting(grok.CodeView):
+class EditCavePainting(grok.View):
 
     grok.context(zope.interface.Interface)
     grok.require(EditPermission)
@@ -80,7 +80,7 @@
     def render(self):
         return 'Let\'s make it even prettier.'
 
-class EraseCavePainting(grok.CodeView):
+class EraseCavePainting(grok.View):
 
     grok.context(zope.interface.Interface)
     grok.require(ErasePermission)
@@ -88,7 +88,7 @@
     def render(self):
         return 'Oops, mistake, let\'s erase it.'
 
-class ApproveCavePainting(grok.CodeView):
+class ApproveCavePainting(grok.View):
 
     grok.context(zope.interface.Interface)
     grok.require(ApprovePermission)

Modified: grok/trunk/src/grok/ftests/traversal/containertraverse.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/containertraverse.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/traversal/containertraverse.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -66,7 +66,7 @@
             return Special()
         return None
     
-class HerdIndex(grok.CodeView):
+class HerdIndex(grok.View):
     grok.context(Herd)
     grok.name('index')
 
@@ -81,7 +81,7 @@
 class Special(grok.Model):
     pass
 
-class SpecialIndex(grok.CodeView):
+class SpecialIndex(grok.View):
     grok.context(Special)
     grok.name('index')
     

Modified: grok/trunk/src/grok/ftests/traversal/containertraverser.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/containertraverser.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/traversal/containertraverser.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -76,7 +76,7 @@
 class Special(grok.Model):
     pass
 
-class SpecialIndex(grok.CodeView):
+class SpecialIndex(grok.View):
     grok.context(Special)
     grok.name('index')
     

Modified: grok/trunk/src/grok/ftests/traversal/items_before_views.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/items_before_views.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/traversal/items_before_views.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -45,7 +45,7 @@
         # the fallback behaviour
         pass
 
-class Ellie(grok.CodeView):
+class Ellie(grok.View):
     grok.context(Herd)
     grok.name('ellie')
 
@@ -56,7 +56,7 @@
     def __init__(self, name):
         self.name = name
 
-class MammothIndex(grok.CodeView):
+class MammothIndex(grok.View):
     grok.context(Mammoth)
     grok.name('index')
 

Modified: grok/trunk/src/grok/ftests/traversal/traversableattr.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/traversableattr.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/traversal/traversableattr.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -40,7 +40,7 @@
     def __init__(self, name):
         self.name = name
 
-class BarIndex(grok.CodeView):
+class BarIndex(grok.View):
     grok.context(Bar)
     grok.name('index')
 
@@ -60,7 +60,7 @@
         return Bar('bar')
     z = "i'm not called"
 
-class FooIndex(grok.CodeView):
+class FooIndex(grok.View):
     grok.context(Foo)
     grok.name('index')
     def render(self):

Modified: grok/trunk/src/grok/ftests/url/application.py
===================================================================
--- grok/trunk/src/grok/ftests/url/application.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/ftests/url/application.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -44,13 +44,13 @@
     pass
 
 
-class Index(grok.CodeView):
+class Index(grok.View):
     grok.context(IMarker)
 
     def render(self):
         return self.application_url()
 
-class Second(grok.CodeView):
+class Second(grok.View):
     grok.context(IMarker)
 
     def render(self):

Modified: grok/trunk/src/grok/tests/baseclass/basedirective.py
===================================================================
--- grok/trunk/src/grok/tests/baseclass/basedirective.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/tests/baseclass/basedirective.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -31,7 +31,7 @@
 class Model(grok.Model):
     pass
 
-class SomeView(grok.CodeView):
+class SomeView(grok.View):
     grok.baseclass()
     
     def render(self):

Modified: grok/trunk/src/grok/tests/container/container_model.py
===================================================================
--- grok/trunk/src/grok/tests/container/container_model.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/tests/container/container_model.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -17,7 +17,7 @@
 class BoneBag(grok.Container):
     pass
 
-class Index(grok.CodeView):
+class Index(grok.View):
     """A simple view to test whether BoneBag is really registered as a model.
     """
     def render(self):

Modified: grok/trunk/src/grok/tests/viewlet/viewlet_references.py
===================================================================
--- grok/trunk/src/grok/tests/viewlet/viewlet_references.py	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/src/grok/tests/viewlet/viewlet_references.py	2009-09-17 09:09:18 UTC (rev 104191)
@@ -43,7 +43,7 @@
 class AContext(grok.Model):
     pass
 
-class ViewWithItems(grok.CodeView):
+class ViewWithItems(grok.View):
     grok.name('with_items')
 
     def render(self):

Modified: grok/trunk/versions.cfg
===================================================================
--- grok/trunk/versions.cfg	2009-09-17 09:07:16 UTC (rev 104190)
+++ grok/trunk/versions.cfg	2009-09-17 09:09:18 UTC (rev 104191)
@@ -1,10 +1,10 @@
 [versions]
 ClientForm = 0.2.9
 grokcore.component = 1.7
-grokcore.formlib = 1.3
+grokcore.formlib = 1.4
 grokcore.security = 1.2
-grokcore.view = 1.11
-grokcore.viewlet = 1.2
+grokcore.view = 1.12.1
+grokcore.viewlet = 1.3
 grokui.admin = 0.4.0
 martian = 0.11
 mechanize = 0.1.7b



More information about the checkins mailing list