[Checkins] SVN: grok/trunk/ merged -r101684:102949 svn+ssh://reinout at svn.zope.org/repos/main/grok/branches/christiancodeviewsplit
Reinout van Rees
reinout at vanrees.org
Wed Aug 19 09:15:50 EDT 2009
Log message for revision 102950:
merged -r101684:102949 svn+ssh://reinout@svn.zope.org/repos/main/grok/branches/christiancodeviewsplit
> WARNING: this does need two other small fixes to get the tests running which I'll do after this commit
Changed:
U grok/trunk/buildout.cfg
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/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
-=-
Modified: grok/trunk/buildout.cfg
===================================================================
--- grok/trunk/buildout.cfg 2009-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/buildout.cfg 2009-08-19 13:15:49 UTC (rev 102950)
@@ -19,6 +19,11 @@
extensions = buildout.dumppickedversions
[versions]
+# Newer release:
+grokcore.view = 1.9
+# Newer releases because of grokcore.view's codeview split:
+grokcore.formlib = 1.2
+grokcore.viewlet = 1.1
[docs]
recipe = zc.recipe.egg
Modified: grok/trunk/src/grok/__init__.py
===================================================================
--- grok/trunk/src/grok/__init__.py 2009-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/__init__.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -71,7 +71,7 @@
ObjectRemovedEvent,
ContainerModifiedEvent)
-from grok.components import Model, View
+from grok.components import Model, View, CodeView
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/components.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -215,9 +215,34 @@
"""The base class for annotation classes in Grok applications."""
-class View(grokcore.view.View):
- """The base class for views 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):
+ """The base class for views with templates in Grok applications.
+
Each class that inherits from `grok.View` is designed to "render" a
category of content objects by reducing them to a document (often an
HTML document). Every view has a name, and is invoked when users
@@ -285,25 +310,9 @@
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/catalog/addform.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -53,14 +53,14 @@
class Mammoth(grok.Model):
grok.implements(IMammoth)
-class Index(grok.View):
+class Index(grok.CodeView):
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.View):
+class Search(grok.CodeView):
grok.context(Zoo)
def render(self):
Modified: grok/trunk/src/grok/ftests/rest/rest_traverse.py
===================================================================
--- grok/trunk/src/grok/ftests/rest/rest_traverse.py 2009-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/rest/rest_traverse.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -67,7 +67,7 @@
applySkin(self.request, LayerZ, grok.IRESTSkinType)
return MyContent()
-class Index(grok.View):
+class Index(grok.CodeView):
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/security/grok_view.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -23,6 +23,6 @@
class App(grok.Application, grok.Container):
pass
-class Index(grok.View):
+class Index(grok.CodeView):
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/security/handle_exception.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -23,7 +23,7 @@
pass
-class Cave(grok.View):
+class Cave(grok.CodeView):
grok.context(zope.interface.Interface)
@@ -33,7 +33,7 @@
raise CaveWasRobbedError("EVERYTHING GONE! GROK ANGRY!")
-class CaveErrorView(grok.View):
+class CaveErrorView(grok.CodeView):
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/security/preserve_permissions.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -98,11 +98,11 @@
class App(grok.Application, grok.Container):
pass
-class Index(grok.View):
+class Index(grok.CodeView):
def render(self):
return 'Moo!'
-class Manage(grok.View):
+class Manage(grok.CodeView):
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/security/roles.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -64,7 +64,7 @@
grok.permissions(
'paint.ViewPainting', 'paint.EditPainting', 'paint.ErasePainting')
-class CavePainting(grok.View):
+class CavePainting(grok.CodeView):
grok.context(zope.interface.Interface)
grok.require(ViewPermission)
@@ -72,7 +72,7 @@
def render(self):
return 'What a beautiful painting.'
-class EditCavePainting(grok.View):
+class EditCavePainting(grok.CodeView):
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.View):
+class EraseCavePainting(grok.CodeView):
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.View):
+class ApproveCavePainting(grok.CodeView):
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/traversal/containertraverse.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -66,7 +66,7 @@
return Special()
return None
-class HerdIndex(grok.View):
+class HerdIndex(grok.CodeView):
grok.context(Herd)
grok.name('index')
@@ -81,7 +81,7 @@
class Special(grok.Model):
pass
-class SpecialIndex(grok.View):
+class SpecialIndex(grok.CodeView):
grok.context(Special)
grok.name('index')
Modified: grok/trunk/src/grok/ftests/traversal/containertraverser.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/containertraverser.py 2009-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/traversal/containertraverser.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -76,7 +76,7 @@
class Special(grok.Model):
pass
-class SpecialIndex(grok.View):
+class SpecialIndex(grok.CodeView):
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/traversal/items_before_views.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -45,7 +45,7 @@
# the fallback behaviour
pass
-class Ellie(grok.View):
+class Ellie(grok.CodeView):
grok.context(Herd)
grok.name('ellie')
@@ -56,7 +56,7 @@
def __init__(self, name):
self.name = name
-class MammothIndex(grok.View):
+class MammothIndex(grok.CodeView):
grok.context(Mammoth)
grok.name('index')
Modified: grok/trunk/src/grok/ftests/traversal/traversableattr.py
===================================================================
--- grok/trunk/src/grok/ftests/traversal/traversableattr.py 2009-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/traversal/traversableattr.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -40,7 +40,7 @@
def __init__(self, name):
self.name = name
-class BarIndex(grok.View):
+class BarIndex(grok.CodeView):
grok.context(Bar)
grok.name('index')
@@ -60,7 +60,7 @@
return Bar('bar')
z = "i'm not called"
-class FooIndex(grok.View):
+class FooIndex(grok.CodeView):
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/ftests/url/application.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -44,13 +44,13 @@
pass
-class Index(grok.View):
+class Index(grok.CodeView):
grok.context(IMarker)
def render(self):
return self.application_url()
-class Second(grok.View):
+class Second(grok.CodeView):
grok.context(IMarker)
def render(self):
Modified: grok/trunk/src/grok/tests/baseclass/basedirective.py
===================================================================
--- grok/trunk/src/grok/tests/baseclass/basedirective.py 2009-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/tests/baseclass/basedirective.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -31,7 +31,7 @@
class Model(grok.Model):
pass
-class SomeView(grok.View):
+class SomeView(grok.CodeView):
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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/tests/container/container_model.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -17,7 +17,7 @@
class BoneBag(grok.Container):
pass
-class Index(grok.View):
+class Index(grok.CodeView):
"""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-08-19 13:03:54 UTC (rev 102949)
+++ grok/trunk/src/grok/tests/viewlet/viewlet_references.py 2009-08-19 13:15:49 UTC (rev 102950)
@@ -43,7 +43,7 @@
class AContext(grok.Model):
pass
-class ViewWithItems(grok.View):
+class ViewWithItems(grok.CodeView):
grok.name('with_items')
def render(self):
More information about the Checkins
mailing list