[Checkins] SVN: grokcore.rest/trunk/ checkpoint
Christian Klinger
cklinger at novareto.de
Mon Nov 8 06:48:12 EST 2010
Log message for revision 118286:
checkpoint
Changed:
U grokcore.rest/trunk/buildout.cfg
U grokcore.rest/trunk/setup.py
A grokcore.rest/trunk/src/grokcore/__init__.py
U grokcore.rest/trunk/src/grokcore/rest/__init__.py
U grokcore.rest/trunk/src/grokcore/rest/components.py
U grokcore.rest/trunk/src/grokcore/rest/configure.zcml
A grokcore.rest/trunk/src/grokcore/rest/directive.py
U grokcore.rest/trunk/src/grokcore/rest/ftesting.zcml
A grokcore.rest/trunk/src/grokcore/rest/ftests/__init__.py
U grokcore.rest/trunk/src/grokcore/rest/ftests/test_grok_functional.py
U grokcore.rest/trunk/src/grokcore/rest/interfaces.py
U grokcore.rest/trunk/src/grokcore/rest/meta.py
U grokcore.rest/trunk/src/grokcore/rest/meta.zcml
U grokcore.rest/trunk/src/grokcore/rest/publication.py
U grokcore.rest/trunk/src/grokcore/rest/rest.py
U grokcore.rest/trunk/src/grokcore/rest/testing.py
A grokcore.rest/trunk/src/grokcore/rest/tests/__init__.py
-=-
Modified: grokcore.rest/trunk/buildout.cfg
===================================================================
--- grokcore.rest/trunk/buildout.cfg 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/buildout.cfg 2010-11-08 11:48:11 UTC (rev 118286)
@@ -1,80 +1,18 @@
[buildout]
extends = http://svn.zope.org/repos/main/groktoolkit/trunk/grok.cfg
parts =
- docs
- interpreter
- grokwiki
- mkdirs
test
- zpasswd
- zope_conf site_zcml deploy_ini debug_ini
develop =
.
- grokdocs
- grokwiki
versions = versions
extensions = buildout.dumppickedversions
[versions]
-grok =
+grokcore.rest =
-[docs]
-recipe = z3c.recipe.scripts
-eggs = grokdocs
-
-[interpreter]
-recipe = z3c.recipe.scripts
-eggs = grokwiki
- zest.releaser
-interpreter = grokpy
-
-[grokwiki]
-recipe = z3c.recipe.scripts
-eggs = grokwiki
- z3c.evalexception>=2.0
- Paste
- PasteScript
- PasteDeploy
-
-[mkdirs]
-recipe = z3c.recipe.mkdir
-paths =
- ${zope_conf:filestorage}
- ${zope_conf:logfiles}
-
[test]
recipe = zc.recipe.testrunner
eggs =
- grok
- grok[test]
+ grokcore.rest
+ grokcore.rest[test]
defaults = ['--tests-pattern', '^f?tests$', '-v']
-
-# This section is named so that the zpasswd utility is
-# called `zpasswd`
-[zpasswd]
-recipe = z3c.recipe.dev:script
-eggs = grokwiki
-module = zope.app.server.zpasswd
-method = main
-
-[zope_conf]
-recipe = z3c.recipe.template
-input = etc/zope.conf.in
-output = ${buildout:parts-directory}/etc/zope.conf
-filestorage = ${buildout:directory}/var/filestorage
-logfiles = ${buildout:directory}/var/log
-
-[site_zcml]
-recipe = z3c.recipe.template
-input = etc/site.zcml.in
-output = ${buildout:parts-directory}/etc/site.zcml
-
-[deploy_ini]
-recipe = z3c.recipe.template
-input = etc/deploy.ini.in
-output = ${buildout:parts-directory}/etc/deploy.ini
-
-[debug_ini]
-recipe = z3c.recipe.template
-input = etc/debug.ini.in
-output = ${buildout:parts-directory}/etc/debug.ini
Modified: grokcore.rest/trunk/setup.py
===================================================================
--- grokcore.rest/trunk/setup.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/setup.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -14,19 +14,22 @@
)
tests_require = [
- 'zope.app.wsgi',
- 'zope.configuration',
+ 'grokcore.view [test]',
+ 'grokcore.view [security_publication]',
'zope.testing',
+ 'zope.app.wsgi',
+ 'zope.app.appsetup',
+ 'grokcore.content',
]
setup(
- name='grok',
- version='1.4dev',
+ name='grokcore.rest',
+ version='0.1',
author='Grok Team',
author_email='grok-dev at zope.org',
url='http://grok.zope.org',
download_url='http://cheeseshop.python.org/pypi/grok/',
- description='Grok: Now even cavemen can use Zope 3!',
+ description='REST View component for Grok.',
long_description=long_description,
license='ZPL',
classifiers=[
@@ -41,51 +44,14 @@
include_package_data = True,
zip_safe=False,
install_requires=[
- 'ZODB3',
- 'grokcore.annotation >= 1.1',
- 'grokcore.component >= 2.1',
- 'grokcore.content',
- 'grokcore.formlib >= 1.4',
- 'grokcore.json',
- 'grokcore.message',
- 'grokcore.security >= 1.1',
- 'grokcore.site',
- 'grokcore.view',
- 'grokcore.view [security_publication]',
- 'grokcore.viewlet >= 1.3',
- 'martian >= 0.14',
- 'pytz',
'setuptools',
- 'simplejson',
- 'z3c.autoinclude',
- 'zc.catalog',
- 'zope.annotation',
- 'zope.app.appsetup',
- 'zope.app.http',
- 'zope.app.publication',
- 'zope.browserpage',
- 'zope.catalog',
+ 'grokcore.component',
+ 'grokcore.security',
+ 'grokcore.view',
+ 'martian',
'zope.component',
- 'zope.container',
- 'zope.contentprovider',
- 'zope.event',
- 'zope.exceptions',
- 'zope.i18n',
- 'zope.i18nmessageid',
'zope.interface',
- 'zope.intid',
- 'zope.keyreference',
- 'zope.lifecycleevent',
- 'zope.location',
- 'zope.login',
- 'zope.password',
- 'zope.principalregistry',
'zope.publisher',
- 'zope.schema',
- 'zope.security',
- 'zope.securitypolicy',
- 'zope.site',
- 'zope.traversing',
],
tests_require=tests_require,
extras_require={'test': tests_require},
Added: grokcore.rest/trunk/src/grokcore/__init__.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/__init__.py (rev 0)
+++ grokcore.rest/trunk/src/grokcore/__init__.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -0,0 +1,7 @@
+# this is a namespace package
+try:
+ import pkg_resources
+ pkg_resources.declare_namespace(__name__)
+except ImportError:
+ import pkgutil
+ __path__ = pkgutil.extend_path(__path__, __name__)
Modified: grokcore.rest/trunk/src/grokcore/rest/__init__.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/__init__.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/__init__.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -11,93 +11,15 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Grok
-"""
-from zope.interface import implements
-from zope.component import adapts
-from martian import ClassGrokker, InstanceGrokker, GlobalGrokker
-from martian import baseclass
-from martian.error import GrokError, GrokImportError
+from grokcore.component import *
+from grokcore.security import *
+from grokcore.view import *
-from grokcore.component import Adapter, MultiAdapter, GlobalUtility, Context
-from grokcore.component.decorators import subscribe, adapter, implementer
-from grokcore.component.directive import (
- context, name, title, description, provides, global_utility, direct)
+from grokcore.rest.components import REST
+from grokcore.rest.directive import restskin
-from grokcore.content import Model, Container, OrderedContainer
-
-from grokcore.security import Permission
-from grokcore.security import Public
-from grokcore.security import require
-
-from grokcore.view import PageTemplate
-from grokcore.view import PageTemplateFile
-from grokcore.view import DirectoryResource
-from grokcore.view import layer
-from grokcore.view import template
-from grokcore.view import templatedir
-from grokcore.view import skin
-from grokcore.view import url
-from grokcore.view import path
-
-from grokcore.viewlet import Viewlet
-from grokcore.viewlet import ViewletManager
-from grokcore.viewlet import view
-from grokcore.viewlet import viewletmanager
-from grokcore.viewlet import order
-
-from grokcore.formlib import action
-from grokcore.formlib import AutoFields
-from grokcore.formlib import Fields
-
-from grokcore.annotation import Annotation
-
-from grokcore.site import LocalUtility
-from grokcore.site import Site
-from grokcore.site import local_utility
-
-from zope.event import notify
-from zope.site.hooks import getSite
-from zope.lifecycleevent import (
- IObjectCreatedEvent, ObjectCreatedEvent,
- IObjectModifiedEvent, ObjectModifiedEvent,
- IObjectCopiedEvent, ObjectCopiedEvent)
-from zope.app.publication.interfaces import IBeforeTraverseEvent
-
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-
-from zope.container.interfaces import (
- IObjectAddedEvent,
- IObjectMovedEvent,
- IObjectRemovedEvent,
- IContainerModifiedEvent)
-from zope.container.contained import (
- ObjectAddedEvent,
- ObjectMovedEvent,
- ObjectRemovedEvent,
- ContainerModifiedEvent)
-
-from grok.events import ApplicationInitializedEvent
-from grok.components import Application
-from grok.components import View, Form, AddForm, EditForm, DisplayForm
-from grok.components import XMLRPC, REST, JSON
-from grok.components import Traverser
-from grok.components import Indexes
-from grok.components import Role
-from grok.interfaces import IRESTSkinType, IRESTLayer
-from grok.interfaces import IApplicationInitializedEvent
-
-from grok.directive import (
- permissions, site, restskin, traversable)
-
-# BBB These two functions are meant for test fixtures and should be
-# imported from grok.testing, not from grok.
-from grok.testing import grok, grok_component
-
-# Our __init__ provides the grok API directly so using 'import grok' is enough.
-from grok.interfaces import IGrokAPI
+from grokcore.rest.interfaces import IREST, IRESTLayer, IRESTSkinType
from zope.interface import moduleProvides
-moduleProvides(IGrokAPI)
-__all__ = list(IGrokAPI)
+moduleProvides(IREST)
+__all__ = list(IREST)
Modified: grokcore.rest/trunk/src/grokcore/rest/components.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/components.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/components.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -18,355 +18,18 @@
provided here.
"""
-import simplejson
-
import zope.location
-from zope import component
+
from zope import interface
-from zope.securitypolicy.role import Role as securitypolicy_Role
-from zope.publisher.browser import BrowserPage
-from zope.publisher.interfaces import NotFound
-from zope.publisher.interfaces.browser import IBrowserPublisher
+from grokcore.view import ViewSupport
+from grokcore.rest.interfaces import IREST
from zope.publisher.interfaces.http import IHTTPRequest
-from zope.publisher.publish import mapply
-from zope.publisher.defaultview import getDefaultViewName
-from zope.container.interfaces import IReadContainer
-import grok
-import martian.util
-import grokcore.view
-import grokcore.site
-import grokcore.message
-from grok import interfaces, util
-
-# BBB this is for import backward compatibility.
-from grokcore.json import JSON
-from grokcore.content import Model, Container, OrderedContainer
-
-
-class Application(grokcore.site.Site):
- """Mixin for creating Grok application objects.
-
- When a `grok.Container` (or a `grok.Model`, though most developers
- use containers) also inherits from `grok.Application`, it not only
- gains the component registration abilities of a `grok.Site`, but
- will also be listed in the Grok admin control panel as one of the
- applications that the admin can install directly at the root of
- their Zope database.
-
- """
- interface.implements(interfaces.IApplication)
-
-
-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
- category of content objects by reducing them to a document (often an
- HTML document). Every view has a name, and is invoked when users
- visit the URL of an eligible context object followed by the name of
- the view itself::
-
- http://example.com/app/folder/object/viewname
-
- If the view name might conflict with actual content inside of the
- context (in the above URL, the context might already contain an
- attribute or item named ``viewname``), then the URL can be explicit
- that it is asking for a view by preceding its name with ``@@``::
-
- http://example.com/app/folder/object/@@viewname
-
- Instead of returning a full document, views are sometimes used to
- provide only a snippet of information for inclusion in some larger
- document; the view can then be called from inside of another view's
- page template::
-
- <li tal:content="context/@@viewname">snippet goes here</li>
-
- A view class can specify the category of objects that it can render
- by calling the `grok.context()` directive with either a class or an
- interface. Otherwise, Grok will attempt to determine the context
- automatically by searching the view's module for exactly one
- `grok.Model` or `grok.Container` class (or some other class
- providing the interface `IContext`) and using that class, if found.
-
- Grok normally creates a view's name (the name used in URLs) by
- downcasing the name of the view class itself. The developer can
- override this by supplying the `grok.name()` directive instead.
-
- The view name ``index`` is special (this works whether the view
- class itself is named ``Index``, or whether ``grok.name('index')``
- is used instead). A view named ``index`` is used to render an
- object when the user visits its URL without appending a view name.
-
- Each view needs to generate and return a document. There are two
- ways of doing so: either the view can provide a `render()` method
- that returns a document, or the view can be associated with a page
- template that Grok will. Page templates can be associated with a
- view in three different ways:
-
- * Grok will automatically associate a view with a page template
- defined in an accompanying ``templates`` directory. If a view
- class ``MammothList`` occurs in a module ``<src>/animal.py``, for
- example, then Grok will look for a page template with the name
- ``<src>/animal_templates/mammothlist.pt``, where ``.pt`` can be
- any page-template extension recognized by Grok.
-
- * Grok will automatically associate a view with a page template
- object in the same module whose name is the downcased name of the
- view class itself. For example, a view ``MammothList`` might be
- defined in a module alongside an actual template instance named
- ``mammothlist``.
-
- * The developer can explicitly define the path to the page template
- file by providing the ``grok.template()`` directive.
-
- Before a page template is rendered, Grok will call the `update()`
- method on the view, if one is supplied, which can pre-compute values
- that the template will need to display. Both `render()` methods and
- `update()` methods will find the context for which the view is being
- rendered under ``self.context``.
-
- """
- interface.implements(interfaces.IGrokView)
-
- def application_url(self, name=None, data=None):
- """Return the URL of the nearest enclosing `grok.Application`."""
- return util.application_url(self.request, self.context, name, data)
-
- def flash(self, message, type='message'):
- """Send a short message to the user."""
- grokcore.message.send(message, type=type, name='session')
-
-
-class Form(grokcore.formlib.Form, View):
- """The base class for forms in Grok applications.
-
- A class that inherits from `grok.Form` is a `grok.View` whose
- template will be given information about the fields in its context,
- and use that information to render an HTML form for adding or
- editing the form. Generally developers use one of the subclasses:
-
- * `grok.AddForm`
- * `grok.DisplayForm`
- * `grok.EditForm`
-
- """
- interface.implements(interfaces.IGrokForm)
-
-
-class AddForm(grokcore.formlib.AddForm, View):
- """Base class for add forms in Grok applications."""
- interface.implements(interfaces.IGrokForm)
-
-
-class DisplayForm(grokcore.formlib.DisplayForm, View):
- """Base class for display forms in Grok applications."""
- interface.implements(interfaces.IGrokForm)
-
-
-class EditForm(grokcore.formlib.EditForm, View):
- """Base class for edit forms in Grok applications."""
- interface.implements(interfaces.IGrokForm)
-
-
-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
- creating an XML-RPC view. Like other Grok views, each `grok.XMLRPC`
- component can either use an explicit `grok.context()` directive to
- specify the kind of object it wraps, or else Grok will look through
- the same module for exactly one `grok.Model` or `grok.Container` (or
- other `IGrokContext` implementor) and make that class its context
- instead.
-
- Every object that is an instance of the wrapped class or interface
- becomes a legitimate XML-RPC server URL, offering as available
- procedures whatever methods have been defined inside of that
- `grok.XMLRPC` component. When a method is called over XML-RPC, any
- parameters are translated into normal Python data types and supplied
- as normal positional arguments. When the method returns a value or
- raises an exception, the result is converted back into an XML-RPC
- response for the client. In both directions, values are marshalled
- transparently to and from XML-RPC data structures.
-
- During the execution of an XML-RPC method, the object whose URL was
- used for the XML-RPC call is available as ``self.context``.
-
- """
-
-
-class REST(zope.location.Location, ViewishViewSupport):
+class REST(zope.location.Location, ViewSupport):
"""Base class for REST views in Grok applications."""
- interface.implements(interfaces.IREST)
+ interface.implements(IREST)
def __init__(self, context, request):
self.context = self.__parent__ = context
self.request = request
-
-
-class Traverser(object):
- """Base class for traversers in Grok applications."""
- interface.implements(IBrowserPublisher)
-
- def __init__(self, context, request):
- self.context = context
- self.request = request
-
- def browserDefault(self, request):
- # if we have a RESTful request, we will handle
- # GET, POST and HEAD differently (PUT and DELETE are handled already
- # but not on the BrowserRequest layer but the HTTPRequest layer)
- if interfaces.IRESTLayer.providedBy(request):
- rest_view = component.getMultiAdapter(
- (self.context, self.request), name=request.method)
- return rest_view, ()
- view_name = getDefaultViewName(self.context, request)
- view_uri = "@@%s" % view_name
- return self.context, (view_uri,)
-
- def publishTraverse(self, request, name):
- subob = self.traverse(name)
- if subob is not None:
- return util.safely_locate_maybe(subob, self.context, name)
-
- traversable_dict = grok.traversable.bind().get(self.context)
- if traversable_dict:
- if name in traversable_dict:
- subob = getattr(self.context, traversable_dict[name])
- if callable(subob):
- subob = subob()
- return util.safely_locate_maybe(subob, self.context, name)
-
- # XXX Special logic here to deal with containers. It would be
- # good if we wouldn't have to do this here. One solution is to
- # rip this out and make you subclass ContainerTraverser if you
- # wanted to override the traversal behaviour of containers.
- if IReadContainer.providedBy(self.context):
- item = self.context.get(name)
- if item is not None:
- return item
-
- view = component.queryMultiAdapter((self.context, request), name=name)
- if view is not None:
- return view
-
- raise NotFound(self.context, name, request)
-
- def traverse(self, name):
- # this will be overridden by subclasses
- pass
-
-
-class ContextTraverser(Traverser):
- """Base class for context traversers in Grok applications.
-
- A context traverser is like a normal `grok.Traverser` but, instead
- of supplying its own `traverse()` method, it directs Grok to go call
- the ``traverse()`` method on the context itself in order to process
- the next name in the URL.
-
- """
- component.adapts(interfaces.IContext, IHTTPRequest)
-
- def traverse(self, name):
- traverse = getattr(self.context, 'traverse', None)
- if traverse:
- return traverse(name)
-
-
-class ContainerTraverser(Traverser):
- """Base class for container traversers in Grok applications.
-
- A container traverser is like a normal `grok.Traverser` but, instead
- of supplying its own ``traverse()`` method, Grok will either call
- the ``traverse()`` method on the context itself, if any, else call
- ``get()`` on the container (a getitem-style lookup) in order to
- resolve the next name in the URL.
-
- """
- component.adapts(interfaces.IContainer, IHTTPRequest)
-
- def traverse(self, name):
- traverse = getattr(self.context, 'traverse', None)
- if traverse:
- result = traverse(name)
- if result is not None:
- return result
- # try to get the item from the container
- return self.context.get(name)
-
-
-class IndexesClass(object):
- """Base class for index collections in a Grok application.
-
- A `grok.Indexes` utility provides one or more Zope Database content
- indexes for use in a `grok.Site` or `grok.Application`. The site or
- application that the indexes are intended for should be named with
- the `grok.site()` directive, and the kind of object to index should
- be named with a `grok.context()` directive.
-
- Inside their class, the developer should specify one or more
- `grok.index.Field` instances naming object attributes that should be
- indexed (and therefore searchable)::
-
- class ArticleIndex(grok.Indexes):
- grok.site(Newspaper)
- grok.context(Article)
- author = index.Field()
- title = index.Field()
- body = index.Text()
-
- See the `grok.index` module for more information on field types.
-
- Note that indexes are persistent: they are stored in the Zope
- database alongside the site or application that they index. They
- are created when the site or application is first created, and so an
- already-created site will not change just because the definition of
- one of its `grok.Indexes` changes; it will either have to be deleted
- and re-created, or some other operation performed to bring its
- indexes up to date.
-
- """
- def __init__(self, name, bases=(), attrs=None):
- if attrs is None:
- return
- indexes = {}
- for name, value in attrs.items():
- # Ignore everything that's not an index definition object
- # except for values set by directives
- if '.' in name:
- setattr(self, name, value)
- continue
- if not interfaces.IIndexDefinition.providedBy(value):
- continue
- indexes[name] = value
- self.__grok_indexes__ = indexes
- # __grok_module__ is needed to make defined_locally() return True for
- # inline templates
- self.__grok_module__ = martian.util.caller_module()
-
-Indexes = IndexesClass('Indexes')
-
-
-class Role(securitypolicy_Role):
- """Base class for roles in Grok applications.
-
- A role is a description of a class of users that gives them a
- machine-readable name, a human-readable title, and a set of
- permissions which users belong to that role should possess::
-
- class Editor(grok.Role):
- grok.name('news.Editor')
- grok.title('Editor')
- grok.permissions('news.EditArticle', 'news.PublishArticle')
-
- """
Modified: grokcore.rest/trunk/src/grokcore/rest/configure.zcml
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/configure.zcml 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/configure.zcml 2010-11-08 11:48:11 UTC (rev 118286)
@@ -3,57 +3,8 @@
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:grok="http://namespaces.zope.org/grok">
- <include package="zope.app.publication" file="meta.zcml" />
- <include package="zope.browserpage" file="meta.zcml" />
- <include package="zope.component" file="meta.zcml" />
- <include package="zope.i18n" file="meta.zcml" />
- <include package="zope.principalregistry" file="meta.zcml" />
- <include package="zope.publisher" file="meta.zcml" />
- <include package="zope.security" file="meta.zcml" />
- <include package="zope.securitypolicy" file="meta.zcml" />
+ <include file="meta.zcml" />
- <include package="grok" file="meta.zcml" />
-
- <include package="zope.app.appsetup" />
- <include package="zope.app.http" />
- <include package="zope.app.publication" />
- <include package="zope.annotation" />
- <include package="zope.browserpage" />
- <include package="zope.catalog" />
- <include package="zope.component" />
- <include package="zope.contentprovider" />
- <include package="zope.intid" />
- <include package="zope.keyreference" />
- <include package="zope.location" />
- <include package="zope.login" />
- <include package="zope.password" />
- <include package="zope.principalregistry" />
- <include package="zope.publisher" />
- <include package="zope.security " />
- <include package="zope.securitypolicy" />
- <include package="zope.site" />
- <include package="zope.traversing" />
- <include package="zope.traversing.browser" />
-
- <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" />
- <include package="grokcore.viewlet" />
-
- <securityPolicy
- component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
- <adapter factory=".components.ContextTraverser" />
- <adapter factory=".components.ContainerTraverser" />
-
- <browser:defaultView
- for=".interfaces.IContext"
- name="index"
- />
-
<!-- we register a ++rest++ traversal namespace -->
<adapter
factory=".rest.rest_skin"
@@ -66,21 +17,12 @@
the same name; we also need to change the priority because of
the ZCML discriminator -->
<publisher
- name="XMLRPC"
- factory=".publication.GrokXMLRPCFactory"
- methods="POST"
- mimetypes="text/xml"
- priority="21"
- />
-
- <publisher
name="HTTP"
factory=".publication.GrokHTTPFactory"
methods="*"
mimetypes="*"
priority="1"
/>
-
<!-- need to grok this for some basic REST support -->
<grok:grok package=".rest" />
Added: grokcore.rest/trunk/src/grokcore/rest/directive.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/directive.py (rev 0)
+++ grokcore.rest/trunk/src/grokcore/rest/directive.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -0,0 +1,22 @@
+import martian
+from grokcore.view.directive import TaggedValueStoreOnce
+
+
+class restskin(martian.Directive):
+ """The `grok.restskin()` directive.
+
+ This directive is placed inside of `grok.IRESTLayer` subclasses to
+ indicate what their layer name will be within a REST URL. Giving
+ the skin ``grok.restskin('b')``, for example, will enable URLs that
+ look something like `http://localhost/++rest++b/app`.
+
+ """
+ # We cannot do any better than to check for a class scope. Ideally we
+ # would've checked whether the context is indeed an Interface class.
+ scope = martian.CLASS
+ store = TaggedValueStoreOnce()
+ validate = martian.validateText
+
+ def factory(self, value=None):
+ return value
+
Modified: grokcore.rest/trunk/src/grokcore/rest/ftesting.zcml
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/ftesting.zcml 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/ftesting.zcml 2010-11-08 11:48:11 UTC (rev 118286)
@@ -2,57 +2,11 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:grok="http://namespaces.zope.org/grok"
xmlns:browser="http://namespaces.zope.org/browser"
- i18n_domain="grok"
- package="grok">
+ i18n_domain="grokcore.rest"
+ package="grokcore.rest">
- <include package="zope.security" file="meta.zcml"/>
-
- <permission title="grok.test"
- id="grok.test"/>
-
- <include package="grok" />
- <grok:grok package="grok.ftests" />
-
- <browser:defaultView name="index.html" />
-
- <securityPolicy
- component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
- />
-
-
- <unauthenticatedPrincipal id="zope.anybody"
- title="Unauthenticated User" />
- <unauthenticatedGroup id="zope.Anybody"
- title="Unauthenticated Users" />
- <authenticatedGroup id="zope.Authenticated"
- title="Authenticated Users" />
- <everybodyGroup id="zope.Everybody"
- title="All Users" />
-
- <grant
- permission="grok.test"
- principal="zope.Authenticated"/>
-
- <grant
- permission="zope.View"
- principal="zope.anybody"
- />
-
- <principal
- id="zope.mgr"
- title="Manager"
- login="mgr"
- password="mgrpw"
- />
-
- <principal
- id="sample.user"
- title="foo"
- login="foo"
- password="secret"
- />
-
- <role id="zope.Manager" title="Site Manager" />
- <grantAll role="zope.Manager" />
- <grant role="zope.Manager" principal="zope.mgr" />
+ <include package="grokcore.view" file="ftesting.zcml"/>
+ <include package="grokcore.rest" />
+ <include package="grokcore.view" file="publication_security.zcml" />
+ <grok:grok package=".ftests" />
</configure>
Added: grokcore.rest/trunk/src/grokcore/rest/ftests/__init__.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/ftests/__init__.py (rev 0)
+++ grokcore.rest/trunk/src/grokcore/rest/ftests/__init__.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -0,0 +1 @@
+# make me a package
Modified: grokcore.rest/trunk/src/grokcore/rest/ftests/test_grok_functional.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/ftests/test_grok_functional.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/ftests/test_grok_functional.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -1,12 +1,12 @@
import re
import unittest, doctest
-import grok
+import grokcore.rest
from pkg_resources import resource_listdir
from zope.testing import renormalizing
from zope.app.wsgi.testlayer import BrowserLayer, http
-FunctionalLayer = BrowserLayer(grok)
+FunctionalLayer = BrowserLayer(grokcore.rest)
checker = renormalizing.RENormalizing([
# Accommodate to exception wrapping in newer versions of mechanize
@@ -41,7 +41,7 @@
if filename == '__init__.py':
continue
- dottedname = 'grok.ftests.%s.%s' % (name, filename[:-3])
+ dottedname = 'grokcore.rest.ftests.%s.%s' % (name, filename[:-3])
test = doctest.DocTestSuite(
dottedname,
checker=checker,
@@ -58,10 +58,7 @@
def test_suite():
suite = unittest.TestSuite()
- for name in [
- 'xmlrpc',
- 'traversal', 'form', 'url', 'security', 'rest',
- 'catalog', 'site', 'application', 'viewlet', 'lifecycle']:
+ for name in ['rest']:
suite.addTest(suiteFromPackage(name))
return suite
Modified: grokcore.rest/trunk/src/grokcore/rest/interfaces.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/interfaces.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/interfaces.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -15,159 +15,28 @@
"""
from zope import interface
from zope.interface.interfaces import IInterface
-from zope.component.interfaces import IObjectEvent
from zope.publisher.interfaces.http import IHTTPRequest
-from zope.container.interfaces import IContainer as IContainerBase
+
# Expose interfaces from grokcore.* packages as well:
-import grokcore.annotation.interfaces
import grokcore.component.interfaces
-import grokcore.formlib.interfaces
-import grokcore.json.interfaces
import grokcore.security.interfaces
-import grokcore.site.interfaces
import grokcore.view.interfaces
-import grokcore.viewlet.interfaces
-from grokcore.component.interfaces import IContext
-from grokcore.component.interfaces import IGrokErrors
-class IGrokBaseClasses(grokcore.annotation.interfaces.IBaseClasses,
- grokcore.component.interfaces.IBaseClasses,
- grokcore.security.interfaces.IBaseClasses,
- grokcore.site.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.")
+class IBaseClasses(grokcore.component.interfaces.IBaseClasses,
+ grokcore.view.interfaces.IBaseClasses,
+ grokcore.security.interfaces.IBaseClasses):
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.")
- Role = interface.Attribute("Base class for roles.")
-class IGrokDirectives(grokcore.component.interfaces.IDirectives,
- grokcore.security.interfaces.IDirectives,
- grokcore.site.interfaces.IDirectives,
- grokcore.view.interfaces.IDirectives):
- def permissions(permissions):
- """Specify the permissions that comprise a role.
- """
- def site(class_or_interface):
- """Specifies the site that an indexes definition is for.
-
- It can only be used inside grok.Indexes subclasses.
- """
-
-
-class IGrokEvents(interface.Interface):
-
- IObjectCreatedEvent = interface.Attribute("")
-
- ObjectCreatedEvent = interface.Attribute("")
-
- IObjectModifiedEvent = interface.Attribute("")
-
- ObjectModifiedEvent = interface.Attribute("")
-
- IObjectCopiedEvent = interface.Attribute("")
-
- ObjectCopiedEvent = interface.Attribute("")
-
- IObjectAddedEvent = interface.Attribute("")
-
- ObjectAddedEvent = interface.Attribute("")
-
- IObjectMovedEvent = interface.Attribute("")
-
- ObjectMovedEvent = interface.Attribute("")
-
- IObjectRemovedEvent = interface.Attribute("")
-
- ObjectRemovedEvent = interface.Attribute("")
-
- IContainerModifiedEvent = interface.Attribute("")
-
- ContainerModifiedEvent = interface.Attribute("")
-
- IBeforeTraverseEvent = interface.Attribute("")
-
- IApplicationInitializedEvent = interface.Attribute("")
-
- ApplicationInitializedEvent = interface.Attribute("")
-
-
-class IGrokAPI(grokcore.formlib.interfaces.IGrokcoreFormlibAPI,
- grokcore.security.interfaces.IGrokcoreSecurityAPI,
- grokcore.site.interfaces.IGrokcoreSiteAPI,
- grokcore.view.interfaces.IGrokcoreViewAPI,
- grokcore.viewlet.interfaces.IGrokcoreViewletAPI,
- IGrokBaseClasses, IGrokDirectives,
- IGrokEvents, IGrokErrors):
-
- # BBB this is deprecated
- def grok(dotted_name):
- """Grok a module or package specified by ``dotted_name``.
-
- NOTE: This function will be removed from the public Grok
- public API. For tests and interpreter sessions, use
- grok.testing.grok().
- """
-
- # BBB this is deprecated
- def grok_component(name, component, context=None, module_info=None,
- templates=None):
- """Grok an arbitrary object. Can be useful during testing.
-
- name - the name of the component (class name, or global instance name
- as it would appear in a module).
- component - the object (class, etc) to grok.
- context - the context object (optional).
- module_info - the module being grokked (optional).
- templates - the templates registry (optional).
-
- Note that context, module_info and templates might be required
- for some grokkers which rely on them.
-
- NOTE: This function will be removed from the public Grok
- public API. For tests and interpreter sessions, use
- grok.testing.grok_component().
- """
-
- def notify(event):
- """Send ``event`` to event subscribers."""
-
- def getSite():
- """Get the current site."""
-
- IRESTSkinType = interface.Attribute('The REST skin type')
-
-
-class IGrokView(grokcore.view.interfaces.IGrokView):
- """Grok views all provide this interface."""
-
- def application_url(name=None):
- """Return the URL of the closest application object in the
- hierarchy or the URL of a named object (``name`` parameter)
- relative to the closest application object.
- """
-
- def flash(message, type='message'):
- """Send a short message to the user."""
-
-
-class IGrokForm(grokcore.formlib.interfaces.IGrokForm, IGrokView):
- """All Grok forms provides this interface."""
-
-
-class IREST(interface.Interface):
+class IREST(grokcore.component.interfaces.IGrokcoreComponentAPI,
+ grokcore.security.interfaces.IGrokcoreSecurityAPI,
+ grokcore.view.interfaces.IGrokcoreViewAPI,
+ IBaseClasses):
context = interface.Attribute("Object that the REST handler presents.")
request = interface.Attribute("Request that REST handler was looked"
@@ -177,18 +46,7 @@
"""The text of the request body.""")
-class IIndexDefinition(interface.Interface):
- """Define an index for grok.Indexes.
- """
- def setup(catalog, name, context):
- """Set up index called name in given catalog.
-
- Use name for index name and attribute to index. Set up
- index for interface or class context.
- """
-
-
class IRESTLayer(IHTTPRequest):
"""REST-specific Request functionality.
@@ -199,17 +57,3 @@
class IRESTSkinType(IInterface):
"""Skin type for REST requests.
"""
-
-
-class IContainer(IContext, IContainerBase):
- """A Grok container.
- """
-
-
-class IApplicationInitializedEvent(IObjectEvent):
- """A Grok Application has been created with success and is now ready
- to be used.
-
- This event can be used to trigger the creation of contents or other tasks
- that require the application to be fully operational : utilities installed
- and indexes created in the catalog."""
Modified: grokcore.rest/trunk/src/grokcore/rest/meta.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/meta.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/meta.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -21,91 +21,25 @@
of a Grok-based web application.
"""
-import zope.component.interface
from zope import interface, component
from zope.interface.interface import InterfaceClass
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.publisher.interfaces.http import IHTTPRequest
-from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
-from zope.securitypolicy.interfaces import IRole
-from zope.securitypolicy.rolepermission import rolePermissionManager
-
-from zope.i18nmessageid import Message
-from zope.intid import IntIds
-from zope.intid.interfaces import IIntIds
-from zope.catalog.catalog import Catalog
-from zope.catalog.interfaces import ICatalog
-from zope.location import Location
-from zope.exceptions.interfaces import DuplicationError
-from zope.publisher.xmlrpc import XMLRPCView
-
import martian
+import grokcore.rest
+import grokcore.component
+import grokcore.view
+import grokcore.security
from martian.error import GrokError
-import grok
-from grok import components
-from grok.interfaces import IRESTSkinType
-
-import grokcore.site.interfaces
from grokcore.security.meta import PermissionGrokker
from grokcore.view import make_checker
-class MethodPublisher(XMLRPCView, Location):
- """Copied from zope.app.publisher.xmlrpc to get rid of that dependency.
- """
- def __getParent(self):
- return hasattr(self, '_parent') and self._parent or self.context
- def __setParent(self, parent):
- self._parent = parent
- __parent__ = property(__getParent, __setParent)
-
-
-class XMLRPCGrokker(martian.MethodGrokker):
- """Grokker for methods of a `grok.XMLRPC` subclass.
-
- When an application defines a `grok.XMLRPC` 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 an XML-RPC adapter for the context, and the
- other to prepare a security check for the adapter.
-
- """
- martian.component(grok.XMLRPC)
- martian.directive(grok.context)
- martian.directive(grok.require, name='permission')
-
- def execute(self, factory, method, config, context, permission, **kw):
- name = method.__name__
-
- # Make sure that the class inherits MethodPublisher, so that the
- # views have a location
- method_view = type(
- factory.__name__, (factory, MethodPublisher),
- {'__call__': method})
-
- adapts = (context, IXMLRPCRequest)
- 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 RESTGrokker(martian.MethodGrokker):
"""Grokker for methods of a `grok.REST` subclass.
@@ -124,10 +58,10 @@
subclass defines.
"""
- martian.component(grok.REST)
- martian.directive(grok.context)
- martian.directive(grok.layer, default=grok.IRESTLayer)
- martian.directive(grok.require, name='permission')
+ martian.component(grokcore.rest.REST)
+ martian.directive(grokcore.component.context)
+ martian.directive(grokcore.view.layer, default=grokcore.rest.IRESTLayer)
+ martian.directive(grokcore.security.require, name='permission')
def execute(self, factory, method, config, permission, context,
layer, **kw):
@@ -171,14 +105,14 @@
# application module! So we have to do our own filtering, by
# checking whether each interface includes the `grok.restskin()`
# directive, and skipping those that do not.
- restskin = grok.restskin.bind(default=_restskin_not_used
- ).get(interface)
+ restskin = grokcore.rest.restskin.bind(default=_restskin_not_used
+ ).get(interface)
if restskin is _restskin_not_used:
# The restskin directive is not actually used on the found
# interface.
return False
- if not interface.extends(grok.IRESTLayer):
+ if not interface.extends(grokcore.rest.IRESTLayer):
# For REST layers it is required to extend IRESTLayer.
raise GrokError(
"The grok.restskin() directive is used on interface %r. "
@@ -190,186 +124,7 @@
config.action(
discriminator=('restprotocol', restskin),
- callable=zope.component.interface.provideInterface,
- args=(restskin, interface, IRESTSkinType))
+ callable=component.interface.provideInterface,
+ args=(restskin, interface, grokcore.rest.IRESTSkinType))
return True
-
-
-class TraverserGrokker(martian.ClassGrokker):
- """Grokker for subclasses of `grok.Traverser`."""
- martian.component(grok.Traverser)
- martian.directive(grok.context)
-
- def execute(self, factory, config, context, **kw):
- adapts = (context, IHTTPRequest)
- config.action(
- discriminator=('adapter', adapts, IBrowserPublisher, ''),
- callable=component.provideAdapter,
- args=(factory, adapts, IBrowserPublisher),
- )
- return True
-
-
-def default_fallback_to_name(factory, module, name, **data):
- return name
-
-
-class RoleGrokker(martian.ClassGrokker):
- """Grokker for components subclassed from `grok.Role`.
-
- Each role is registered as a global utility providing the service
- `IRole` under its own particular name, and then granted every
- permission named in its `grok.permission()` directive.
-
- """
- martian.component(grok.Role)
- martian.priority(martian.priority.bind().get(PermissionGrokker()) - 1)
- martian.directive(grok.name)
- martian.directive(grok.title, get_default=default_fallback_to_name)
- martian.directive(grok.description)
- martian.directive(grok.permissions)
-
- def execute(self, factory, config, name, title, description,
- permissions, **kw):
- if not name:
- raise GrokError(
- "A role needs to have a dotted name for its id. Use "
- "grok.name to specify one.", factory)
- # We can safely convert to unicode, since the directives makes sure
- # it is either unicode already or ASCII.
- if not isinstance(title, Message):
- title = unicode(title)
- if not isinstance(description, Message):
- description = unicode(description)
- role = factory(unicode(name), title, description)
-
- config.action(
- discriminator=('utility', IRole, name),
- callable=component.provideUtility,
- args=(role, IRole, name),
- )
-
- for permission in permissions:
- config.action(
- discriminator=('grantPermissionToRole', permission, name),
- callable=rolePermissionManager.grantPermissionToRole,
- args=(permission, name),
- )
- return True
-
-
-class ApplicationGrokker(martian.ClassGrokker):
- """Grokker for Grok application classes."""
- martian.component(grok.Application)
- martian.priority(500)
-
- def grok(self, name, factory, module_info, config, **kw):
- # XXX fail loudly if the same application name is used twice.
- provides = grok.interfaces.IApplication
- name = '%s.%s' % (module_info.dotted_name, name)
- config.action(
- discriminator=('utility', provides, name),
- callable=component.provideUtility,
- args=(factory, provides, name),
- )
- return True
-
-
-class IndexesGrokker(martian.InstanceGrokker):
- """Grokker for Grok index bundles."""
- martian.component(components.IndexesClass)
-
- def grok(self, name, factory, module_info, config, **kw):
- site = grok.site.bind().get(factory)
- context = grok.context.bind().get(factory, module_info.getModule())
- catalog_name = grok.name.bind().get(factory)
-
- if site is None:
- raise GrokError("No site specified for grok.Indexes "
- "subclass in module %r. "
- "Use grok.site() to specify."
- % module_info.getModule(),
- factory)
- indexes = getattr(factory, '__grok_indexes__', None)
- if indexes is None:
- return False
-
- subscriber = IndexesSetupSubscriber(catalog_name, indexes,
- context, module_info)
- subscribed = (site, grok.IObjectAddedEvent)
- config.action(
- discriminator=None,
- callable=component.provideHandler,
- args=(subscriber, subscribed),
- )
- return True
-
-
-class IndexesSetupSubscriber(object):
- """Helper that sets up indexes when their Grok site is created.
-
- Each `grok.Indexes` class serves as an assertion that, whenever an
- instance of its `grok.site()` is created, the given list of indexes
- should be generated as well. But a long period of time could elapse
- between when the application starts (and its indexes are grokked),
- and the moment, maybe days or weeks later, when a new instance of
- that `grok.Site` is created. Hence this `IndexesSetupSubscriber`:
- it can be instantiated at grokking time with the index information,
- and then registered with the Component Architecture as an event that
- should be fired later, whenever the right kind of `grok.Site` is
- instantiated. At that point its `__call__` method is kicked off and
- it makes sure the index catalogs get created properly.
-
- """
- def __init__(self, catalog_name, indexes, context, module_info):
- self.catalog_name = catalog_name
- self.indexes = indexes
- self.context = context
- self.module_info = module_info
-
- def __call__(self, site, event):
- # make sure we have an intids
- self._createIntIds(site)
- # get the catalog
- catalog = self._createCatalog(site)
- # now install indexes
- for name, index in self.indexes.items():
- try:
- index.setup(catalog, name, self.context, self.module_info)
- except DuplicationError:
- raise GrokError(
- "grok.Indexes in module %r causes "
- "creation of catalog index %r in catalog %r, "
- "but an index with that name is already present." %
- (self.module_info.getModule(), name, self.catalog_name),
- None)
-
- def _createCatalog(self, site):
- """Create the catalog if needed and return it.
-
- If the catalog already exists, return that.
-
- """
- catalog = zope.component.queryUtility(
- ICatalog, name=self.catalog_name, context=site, default=None)
- if catalog is not None:
- return catalog
- catalog = Catalog()
- setupUtility = component.getUtility(
- grokcore.site.interfaces.IUtilityInstaller)
- setupUtility(site, catalog, ICatalog, name=self.catalog_name)
- return catalog
-
- def _createIntIds(self, site):
- """Create intids if needed, and return it.
- """
- intids = zope.component.queryUtility(
- IIntIds, context=site, default=None)
- if intids is not None:
- return intids
- intids = IntIds()
- setupUtility = component.getUtility(
- grokcore.site.interfaces.IUtilityInstaller)
- setupUtility(site, intids, IIntIds)
- return intids
Modified: grokcore.rest/trunk/src/grokcore/rest/meta.zcml
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/meta.zcml 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/meta.zcml 2010-11-08 11:48:11 UTC (rev 118286)
@@ -3,16 +3,10 @@
xmlns:meta="http://namespaces.zope.org/meta"
xmlns:grok="http://namespaces.zope.org/grok">
- <include package="z3c.autoinclude" file="meta.zcml" />
-
<!-- Load the grokkers -->
<include package="grokcore.component" file="meta.zcml" />
- <include package="grokcore.formlib" file="meta.zcml" />
- <include package="grokcore.security" file="meta.zcml" />
<include package="grokcore.view" file="meta.zcml" />
- <include package="grokcore.viewlet" file="meta.zcml" />
- <include package="grokcore.annotation" file="meta.zcml" />
- <include package="grokcore.site" file="meta.zcml" />
+ <include package="grokcore.security" file="meta.zcml" />
<grok:grok package=".meta" />
</configure>
Modified: grokcore.rest/trunk/src/grokcore/rest/publication.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/publication.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/publication.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -23,7 +23,7 @@
object.
"""
-from grok.rest import GrokMethodNotAllowed
+from grokcore.rest.rest import GrokMethodNotAllowed
from grokcore.view.publication import ZopePublicationSansProxy
from zope import component
@@ -36,25 +36,6 @@
XMLRPCFactory, HTTPFactory)
-class GrokXMLRPCPublication(ZopePublicationSansProxy, BaseHTTPPublication):
- """Combines `BaseHTTPPublication` with the Grok sans-proxy mixin."""
-
-
-class GrokXMLRPCFactory(XMLRPCFactory):
- """Returns the classes Grok uses for browser requests and publication.
-
- When an instance of this class is called, it returns a 2-element
- tuple containing:
-
- - The request class that Grok uses for XML-RPC requests.
- - The publication class that Grok uses to publish to a XML-RPC.
-
- """
- def __call__(self):
- request, publication = super(GrokXMLRPCFactory, self).__call__()
- return request, GrokXMLRPCPublication
-
-
class GrokHTTPPublication(ZopePublicationSansProxy, HTTPPublication):
"""Combines `HTTPPublication` with the Grok sans-proxy mixin.
Modified: grokcore.rest/trunk/src/grokcore/rest/rest.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/rest.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/rest.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -5,8 +5,10 @@
been defined. These all return the HTTP response Method Not Allowed.
"""
-import grok
-from grok.interfaces import IRESTSkinType
+import grokcore.component as grok
+import grokcore.rest
+import grokcore.view
+from grokcore.rest.interfaces import IRESTSkinType
from zope import component
from zope.component.interfaces import ComponentLookupError
@@ -80,7 +82,7 @@
return self.context
-class NotAllowedREST(grok.REST):
+class NotAllowedREST(grokcore.rest.REST):
"""Default REST view, whose methods all raise Not Allowed errors.
By binding itself to ``Interface``, this becomes the most general
@@ -90,7 +92,7 @@
clients attempt to assail them with unwanted HTTP methods.
"""
- grok.layer(grok.IRESTLayer)
+ grokcore.view.layer(grokcore.rest.IRESTLayer)
grok.context(Interface)
is_not_allowed = True
Modified: grokcore.rest/trunk/src/grokcore/rest/testing.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/testing.py 2010-11-08 11:39:15 UTC (rev 118285)
+++ grokcore.rest/trunk/src/grokcore/rest/testing.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -25,42 +25,6 @@
zcml.do_grok('grokcore.component.meta', config)
zcml.do_grok('grokcore.security.meta', config)
zcml.do_grok('grokcore.view.meta', config)
- zcml.do_grok('grokcore.view.templatereg', config)
- zcml.do_grok('grokcore.viewlet.meta', config)
- zcml.do_grok('grokcore.formlib.meta', config)
- zcml.do_grok('grokcore.annotation.meta', config)
- zcml.do_grok('grokcore.site.meta', config)
- zcml.do_grok('grok.meta', config)
+ zcml.do_grok('grokcore.rest.meta', config)
zcml.do_grok(module_name, config)
config.execute_actions()
-
-
-def warn(message, category=None, stacklevel=1):
- """Intended to replace warnings.warn in tests.
-
- Modified copy from zope.deprecation.tests to:
-
- * make the signature identical to warnings.warn
- * to check for *.pyc and *.pyo files.
-
- When zope.deprecation is fixed, this warn function can be removed again.
- """
- print "From grok.testing's warn():"
-
- frame = sys._getframe(stacklevel)
- path = frame.f_globals['__file__']
- if path.endswith('.pyc') or path.endswith('.pyo'):
- path = path[:-1]
-
- file = open(path)
- lineno = frame.f_lineno
- for i in range(lineno):
- line = file.readline()
-
- print "%s:%s: %s: %s\n %s" % (
- path,
- frame.f_lineno,
- category.__name__,
- message,
- line.strip(),
- )
Added: grokcore.rest/trunk/src/grokcore/rest/tests/__init__.py
===================================================================
--- grokcore.rest/trunk/src/grokcore/rest/tests/__init__.py (rev 0)
+++ grokcore.rest/trunk/src/grokcore/rest/tests/__init__.py 2010-11-08 11:48:11 UTC (rev 118286)
@@ -0,0 +1 @@
+# make me a package
More information about the checkins
mailing list