[Checkins] SVN: grok/branches/jw-viewsupport-mixin/ integrate ViewSupport in grok.View and grok.REST and grok.XMLRPC and grok.JSON. next is adding more tests for the viewish components.
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Thu Nov 26 13:53:19 EST 2009
Log message for revision 106044:
integrate ViewSupport in grok.View and grok.REST and grok.XMLRPC and grok.JSON. next is adding more tests for the viewish components.
Changed:
_U grok/branches/jw-viewsupport-mixin/
U grok/branches/jw-viewsupport-mixin/buildout.cfg
U grok/branches/jw-viewsupport-mixin/src/grok/components.py
U grok/branches/jw-viewsupport-mixin/src/grok/util.py
-=-
Property changes on: grok/branches/jw-viewsupport-mixin
___________________________________________________________________
Modified: svn:externals
- bootstrap svn://svn.zope.org/repos/main/zc.buildout/trunk/bootstrap/
+ bootstrap svn://svn.zope.org/repos/main/zc.buildout/trunk/bootstrap/
grokcore.view svn+ssh://svn.zope.org/repos/main/grokcore.view/branches/1.13
Modified: grok/branches/jw-viewsupport-mixin/buildout.cfg
===================================================================
--- grok/branches/jw-viewsupport-mixin/buildout.cfg 2009-11-26 18:52:15 UTC (rev 106043)
+++ grok/branches/jw-viewsupport-mixin/buildout.cfg 2009-11-26 18:53:19 UTC (rev 106044)
@@ -14,9 +14,13 @@
.
grokdocs
grokwiki
+ grokcore.view
versions = versions
extensions = buildout.dumppickedversions
+[versions]
+grokcore.view =
+
[docs]
recipe = zc.recipe.egg
eggs = grokdocs
Modified: grok/branches/jw-viewsupport-mixin/src/grok/components.py
===================================================================
--- grok/branches/jw-viewsupport-mixin/src/grok/components.py 2009-11-26 18:52:15 UTC (rev 106043)
+++ grok/branches/jw-viewsupport-mixin/src/grok/components.py 2009-11-26 18:53:19 UTC (rev 106044)
@@ -235,14 +235,9 @@
"""
interface.implements(interfaces.IGrokView)
- def application_url(self, name=None):
+ def application_url(self, name=None, data=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.")
+ return util.application_url(self.request, self.context, name, data)
def flash(self, message, type='message'):
"""Send a short message to the user."""
@@ -284,7 +279,13 @@
interface.implements(interfaces.IGrokForm)
-class XMLRPC(object):
+class ViewishViewSupport(grokcore.view.ViewSupport):
+
+ def application_url(self, name=None, data=None):
+ return util.application_url(self.request, self.context, name, data)
+
+
+class XMLRPC(ViewishViewSupport):
"""Base class for XML-RPC endpoints in Grok applications.
When an application creates a subclass of `grok.XMLRPC`, it is
@@ -311,21 +312,16 @@
"""
-class REST(zope.location.Location):
+class REST(zope.location.Location, ViewishViewSupport):
"""Base class for REST views in Grok applications."""
interface.implements(interfaces.IREST)
def __init__(self, context, request):
self.context = self.__parent__ = context
self.request = request
- self.body = request.bodyStream.getCacheStream().read()
- @property
- def response(self):
- return self.request.response
-
-class JSON(BrowserPage):
+class JSON(BrowserPage, ViewishViewSupport):
"""Base class for JSON views in Grok applications."""
interface.implements(interfaces.IGrokSecurityView)
Modified: grok/branches/jw-viewsupport-mixin/src/grok/util.py
===================================================================
--- grok/branches/jw-viewsupport-mixin/src/grok/util.py 2009-11-26 18:52:15 UTC (rev 106043)
+++ grok/branches/jw-viewsupport-mixin/src/grok/util.py 2009-11-26 18:53:19 UTC (rev 106044)
@@ -21,6 +21,7 @@
from zope.exceptions.interfaces import DuplicationError
from zope.security.checker import NamesChecker, defineChecker
+from grokcore.view.util import url
from grokcore.security.util import check_permission
@@ -91,3 +92,12 @@
grok.notify(grok.ApplicationInitializedEvent(application))
return application
+
+
+def application_url(request, obj, name=None, data={}):
+ """Return the URL of the nearest enclosing `grok.Application`."""
+ while obj is not None:
+ if isinstance(obj, grok.Application):
+ return url(request, obj, name, data)
+ obj = obj.__parent__
+ raise ValueError("No application found.")
More information about the checkins
mailing list