[Checkins] SVN: grok/trunk/ Added CHANGES notes.

Souheil CHELFOUH souheil at chelfouh.com
Wed Nov 3 09:35:25 EDT 2010


Log message for revision 118155:
  Added CHANGES notes.
  Moved the JSON bits out of Grok itself. It now belongs to grokcore.json
  

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

-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt	2010-11-03 13:35:05 UTC (rev 118154)
+++ grok/trunk/CHANGES.txt	2010-11-03 13:35:14 UTC (rev 118155)
@@ -8,6 +8,12 @@
 
 - The `make_checker` util function has been moved to ``grokcore.view``. 
 
+- The base publisher has been moved to ``grokcore.view`` as an
+  optional feature : security_publication.
+
+- The JSON component and grokker are now moved to
+  ``grokcore.json``. Grok now depends on this new grokore package.
+
 - Update to latest martian and grokcore.component.
 
 1.2.1 (2010-10-26)

Modified: grok/trunk/setup.py
===================================================================
--- grok/trunk/setup.py	2010-11-03 13:35:05 UTC (rev 118154)
+++ grok/trunk/setup.py	2010-11-03 13:35:14 UTC (rev 118155)
@@ -29,13 +29,13 @@
     description='Grok: Now even cavemen can use Zope 3!',
     long_description=long_description,
     license='ZPL',
-    classifiers=['Environment :: Web Environment',
-                 'Intended Audience :: Developers',
-                 'License :: OSI Approved :: Zope Public License',
-                 'Programming Language :: Python',
-                 'Framework :: Zope3',
-                 ],
-
+    classifiers=[
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: Zope Public License',
+        'Programming Language :: Python',
+        'Framework :: Zope3',
+        ],
     packages=find_packages('src'),
     package_dir = {'': 'src'},
     include_package_data = True,
@@ -46,6 +46,7 @@
         'grokcore.component',
         'grokcore.content',
         'grokcore.formlib >= 1.4',
+        'grokcore.json',
         'grokcore.message',
         'grokcore.security >= 1.1',
         'grokcore.site',

Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py	2010-11-03 13:35:05 UTC (rev 118154)
+++ grok/trunk/src/grok/components.py	2010-11-03 13:35:14 UTC (rev 118155)
@@ -41,6 +41,7 @@
 from grok import interfaces, util
 
 # BBB this is for import backward compatibility.
+from grokcore.json import JSON
 from grokcore.content import Model, Container, OrderedContainer
 
 
@@ -212,18 +213,6 @@
         self.request = request
 
 
-class JSON(BrowserPage, ViewishViewSupport):
-    """Base class for JSON views in Grok applications."""
-    interface.implements(grokcore.view.IGrokSecurityView)
-
-    def __call__(self):
-        view_name = self.__view_name__
-        method = getattr(self, view_name)
-        method_result = mapply(method, (), self.request)
-        self.request.response.setHeader('Content-Type', 'application/json')
-        return simplejson.dumps(method_result)
-
-
 class Traverser(object):
     """Base class for traversers in Grok applications."""
     interface.implements(IBrowserPublisher)

Modified: grok/trunk/src/grok/configure.zcml
===================================================================
--- grok/trunk/src/grok/configure.zcml	2010-11-03 13:35:05 UTC (rev 118154)
+++ grok/trunk/src/grok/configure.zcml	2010-11-03 13:35:14 UTC (rev 118155)
@@ -37,6 +37,7 @@
 
   <include package="grokcore.annotation" />
   <include package="grokcore.formlib" />
+  <include package="grokcore.json" />
   <include package="grokcore.site" />
   <include package="grokcore.view" />
   <include package="grokcore.view" file="publication_security.zcml" />

Modified: grok/trunk/src/grok/interfaces.py
===================================================================
--- grok/trunk/src/grok/interfaces.py	2010-11-03 13:35:05 UTC (rev 118154)
+++ grok/trunk/src/grok/interfaces.py	2010-11-03 13:35:14 UTC (rev 118155)
@@ -36,14 +36,14 @@
                        grokcore.component.interfaces.IBaseClasses,
                        grokcore.security.interfaces.IBaseClasses,
                        grokcore.site.interfaces.IBaseClasses,
-                       grokcore.view.interfaces.IBaseClasses):
+                       grokcore.view.interfaces.IBaseClasses,
+                       grokcore.json.interfaces.IBaseClasses):
     Model = interface.Attribute("Base class for persistent content objects "
                                 "(models).")
     Container = interface.Attribute("Base class for containers.")
     OrderedContainer = interface.Attribute("Base class for ordered containers.")
     Application = interface.Attribute("Base class for applications.")
     XMLRPC = interface.Attribute("Base class for XML-RPC methods.")
-    JSON = interface.Attribute("Base class for JSON methods.")
     REST = interface.Attribute("Base class for REST views.")
     Traverser = interface.Attribute("Base class for custom traversers.")
     Indexes = interface.Attribute("Base class for catalog index definitions.")

Modified: grok/trunk/src/grok/meta.py
===================================================================
--- grok/trunk/src/grok/meta.py	2010-11-03 13:35:05 UTC (rev 118154)
+++ grok/trunk/src/grok/meta.py	2010-11-03 13:35:14 UTC (rev 118155)
@@ -24,8 +24,7 @@
 import zope.component.interface
 from zope import interface, component
 from zope.interface.interface import InterfaceClass
-from zope.publisher.interfaces.browser import (IDefaultBrowserLayer,
-                                               IBrowserPublisher)
+from zope.publisher.interfaces.browser import IBrowserPublisher
 from zope.publisher.interfaces.http import IHTTPRequest
 
 from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
@@ -198,49 +197,6 @@
         return True
 
 
-class JSONGrokker(martian.MethodGrokker):
-    """Grokker for methods of a `grok.JSON` subclass.
-
-    When an application defines a `grok.JSON` view, we do not actually
-    register the view with the Component Architecture.  Instead, we grok
-    each of its methods separately, placing them each inside of a new
-    class that we create on-the-fly by calling `type()`.  We make each
-    method the `__call__()` method of its new class, since that is how
-    Zope always invokes views.  And it is this new class that is then
-    made the object of the two configuration actions that we schedule:
-    one to activate it as a JSON adapter for the context, and the other
-    to prepare a security check for the adapter.
-
-    """
-    martian.component(grok.JSON)
-    martian.directive(grok.context, get_default=default_context)
-    martian.directive(grok.require, name='permission')
-    martian.directive(grok.layer, default=IDefaultBrowserLayer)
-
-    def execute(
-            self, factory, method, config, context, permission, layer, **kw):
-        # Create a new class with a __view_name__ attribute so the
-        # JSON class knows what method to call.
-        method_view = type(
-            factory.__name__, (factory,),
-            {'__view_name__': method.__name__})
-
-        adapts = (context, layer)
-        name = method.__name__
-
-        config.action(
-            discriminator=('adapter', adapts, interface.Interface, name),
-            callable=component.provideAdapter,
-            args=(method_view, adapts, interface.Interface, name))
-
-        config.action(
-            discriminator=('protectName', method_view, '__call__'),
-            callable=make_checker,
-            args=(factory, method_view, permission))
-
-        return True
-
-
 class TraverserGrokker(martian.ClassGrokker):
     """Grokker for subclasses of `grok.Traverser`."""
     martian.component(grok.Traverser)
@@ -255,9 +211,11 @@
             )
         return True
 
+
 def default_fallback_to_name(factory, module, name, **data):
     return name
 
+
 class RoleGrokker(martian.ClassGrokker):
     """Grokker for components subclassed from `grok.Role`.
 



More information about the checkins mailing list