[Checkins] SVN: grokcore.annotation/trunk/s Remove non-annotation related code and tests.

Sylvain Viollon sylvain at infrae.com
Tue Jun 16 05:06:29 EDT 2009


Log message for revision 101057:
  Remove non-annotation related code and tests.
  
  

Changed:
  U   grokcore.annotation/trunk/setup.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/__init__.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/components.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/configure.zcml
  D   grokcore.annotation/trunk/src/grokcore/annotation/directive.py
  D   grokcore.annotation/trunk/src/grokcore/annotation/ftests/
  D   grokcore.annotation/trunk/src/grokcore/annotation/index.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/interfaces.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/meta.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/meta.zcml
  D   grokcore.annotation/trunk/src/grokcore/annotation/publication.py
  D   grokcore.annotation/trunk/src/grokcore/annotation/rest.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/testing.py
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/adapter/
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/annotation.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsmany.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsnone.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/name.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/provides.py
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/application/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/baseclass/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/catalog/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/conflict/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/container/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/directive/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/error/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/event/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/grokker/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/json/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/security/
  U   grokcore.annotation/trunk/src/grokcore/annotation/tests/test_grok.py
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/testsetup/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/utility/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/viewlet/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/xmlrpc/
  D   grokcore.annotation/trunk/src/grokcore/annotation/tests/zcml/

-=-
Modified: grokcore.annotation/trunk/setup.py
===================================================================
--- grokcore.annotation/trunk/setup.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/setup.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -36,8 +36,9 @@
                       'martian',
                       'zope.component',
                       'zope.interface',
+                      'zope.annotation',
                       'grokcore.component',
                       # for ftests:
-                      'zope.app.zcmlfiles',
+                      'z3c.testsetup',
                       ],
 )

Modified: grokcore.annotation/trunk/src/grokcore/annotation/__init__.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/__init__.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/__init__.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -1,6 +1,6 @@
 ##############################################################################
 #
-# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# Copyright (c) 2006-2009 Zope Corporation and Contributors.
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -11,85 +11,19 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Grok
+"""Grokcore.annotation
 """
-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.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.annotation.components import Annotation
 
-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 zope.event import notify
-from zope.app.component.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.app.container.interfaces import (
-    IObjectAddedEvent,
-    IObjectMovedEvent,
-    IObjectRemovedEvent,
-    IContainerModifiedEvent)
-from zope.app.container.contained import (
-    ObjectAddedEvent,
-    ObjectMovedEvent,
-    ObjectRemovedEvent,
-    ContainerModifiedEvent)
-
-from grok.components import Model, View
-from grok.components import XMLRPC, REST, JSON
-from grok.components import Traverser
-from grok.components import Container, OrderedContainer
-from grok.components import Site, LocalUtility, Annotation
-from grok.components import Application, Form, AddForm, EditForm, DisplayForm
-from grok.components import Indexes
-from grok.components import Role
-from grok.interfaces import IRESTSkinType, IRESTLayer
-
-from grok.directive import (
-    local_utility, 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
+from grokcore.annotation.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.annotation.interfaces import IGrokcoreAnnotationAPI
 from zope.interface import moduleProvides
-moduleProvides(IGrokAPI)
-__all__ = list(IGrokAPI)
+moduleProvides(IGrokcoreAnnotationAPI)
+__all__ = list(IGrokcoreAnnotationAPI)

Modified: grokcore.annotation/trunk/src/grokcore/annotation/components.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/components.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/components.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -13,535 +13,9 @@
 ##############################################################################
 """Base classes for Grok application components.
 
-When an application developer builds a Grok-based application, the
-classes they define each typically inherit from one of the base classes
-provided here.
-
 """
 import persistent
-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 zope.publisher.interfaces.http import IHTTPRequest
-from zope.publisher.publish import mapply
-from zope.annotation.interfaces import IAttributeAnnotatable
 
-from zope.app.publisher.browser import getDefaultViewName
-from zope.app.container.btree import BTreeContainer
-from zope.app.container.contained import Contained
-from zope.app.container.interfaces import IReadContainer, IObjectAddedEvent
-from zope.app.container.interfaces import IOrderedContainer
-from zope.app.container.contained import notifyContainerModified
-from persistent.list import PersistentList
-from zope.app.component.site import SiteManagerContainer
-from zope.app.component.site import LocalSiteManager
-
-import grok
-import z3c.flashmessage.interfaces
-import martian.util
-
-import grokcore.view
-from grok import interfaces, util
-
-
-class Model(Contained, persistent.Persistent):
-    # XXX Inheritance order is important here. If we reverse this,
-    # then containers can't be models anymore because no unambigous MRO
-    # can be established.
-    """The base class for models in Grok applications.
-
-    When an application class inherits from `grok.Model`, it gains the
-    ability to persist itself in the Zope object database along with all
-    of its attributes, and to remember the container in which it has
-    been placed (its "parent") so that its URL can be computed.  It also
-    inherits the `IContext` marker interface, which can make it the
-    default context for views in its module; the rule is that if a
-    module contains `grok.View` classes or other adapters that do not
-    define a `grok.context()`, but the module also defines exactly one
-    class that provides the `IContext` interface, then that class will
-    automatically be made the `grok.context()` of each of the views.
-
-    """
-    interface.implements(IAttributeAnnotatable, interfaces.IContext)
-
-
-class Container(BTreeContainer):
-    """The base class for containers in Grok applications.
-
-    When an application class inherits from `grok.Container`, it not
-    only has the features of a `grok.Model` (persistance, location, and
-    the ability to serve as a default context for other classes), but it
-    also behaves like a persistent dictionary.  To store items inside a
-    container, simply use the standard Python getitem/setitem protocol::
-
-        mycontainer['counter'] = 72
-        mycontainer['address'] = mymodel
-        mycontainer['subfolder'] = another_container
-
-    By default, the URL of each item inside a container is the
-    container's own URL followed by a slash and the key (like 'counter'
-    or 'address') under which that item has been stored.
-
-    """
-    interface.implements(IAttributeAnnotatable, interfaces.IContainer)
-
-
-class OrderedContainer(Container):
-    """A Grok container that remembers the order of its items.
-
-    This straightforward extension of the basic `grok.Container`
-    remembers the order in which items have been inserted, so that
-    `keys()`, `values()`, `items()`, and iteration across the container
-    can all return the items in the order they were inserted.  The only
-    way of changing the order is to call the `updateOrder()` method.
-
-    """
-    interface.implements(IOrderedContainer)
-
-    def __init__(self):
-        super(OrderedContainer, self).__init__()
-        self._order = PersistentList()
-
-    def keys(self):
-        # Return a copy of the list to prevent accidental modifications.
-        return self._order[:]
-
-    def __iter__(self):
-        return iter(self.keys())
-
-    def values(self):
-        return (self[key] for key in self._order)
-
-    def items(self):
-        return ((key, self[key]) for key in self._order)
-
-    def __setitem__(self, key, object):
-        foo = self.has_key(key)
-        # Then do whatever containers normally do.
-        super(OrderedContainer, self).__setitem__(key, object)
-        if not foo:
-            self._order.append(key)
-
-    def __delitem__(self, key):
-        # First do whatever containers normally do.
-        super(OrderedContainer, self).__delitem__(key)
-        self._order.remove(key)
-
-    def updateOrder(self, order):
-        """Impose a new order on the items in this container.
-
-        Items in this container are, by default, returned in the order
-        in which they were inserted.  To change the order, provide an
-        argument to this method that is a sequence containing every key
-        already in the container, but in a new order.
-
-        """
-        if set(order) != set(self._order):
-            raise ValueError("Incompatible key set.")
-
-        self._order = PersistentList()
-        self._order.extend(order)
-        notifyContainerModified(self)
-
-
-class Site(SiteManagerContainer):
-    """Mixin for creating sites in Grok applications.
-
-    When an application `grok.Model` or `grok.Container` also inherits
-    from `grok.Site`, then it can additionally support the registration
-    of local Component Architecture entities like `grok.LocalUtility`
-    and `grok.Indexes` objects; see those classes for more information.
-
-    """
-
-
- at component.adapter(Site, IObjectAddedEvent)
-def addSiteHandler(site, event):
-    """Add a local site manager to a Grok site object upon its creation.
-
-    Grok registers this function so that it gets called each time a
-    `grok.Site` instance is added to a container.  It creates a local
-    site manager and installs it on the newly created site.
-
-    """
-    sitemanager = LocalSiteManager(site)
-    # LocalSiteManager creates the 'default' folder in its __init__.
-    # It's not needed anymore in new versions of Zope 3, therefore we
-    # remove it
-    del sitemanager['default']
-    site.setSiteManager(sitemanager)
-
-
-class Application(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 LocalUtility(Model):
-    """The base class for local utilities in Grok applications.
-
-    Although application developers can create local utilies without
-    actually subclassing `grok.LocalUtility`, they gain three benefits
-    from doing so.  First, their code is more readable because their
-    classes "look like" local utilities to casual readers.  Second,
-    their utility will know how to persist itself to the Zope database,
-    which means that they can set its object attributes and know that
-    the values are getting automatically saved.  Third, they can omit
-    the `grok.provides()` directive naming the interface that the
-    utility provides, if their class only `grok.implements()` a single
-    interface (unless the interface is one that the `grok.LocalUtility`
-    already implements, in which case Grok cannot tell them apart, and
-    `grok.provides()` must be used explicitly anyway).
-
-    """
-
-
 class Annotation(persistent.Persistent):
     """The base class for annotation classes in Grok applications."""
-
-
-class View(grokcore.view.View):
-    """The base class for views 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):
-        """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.
-
-    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 XMLRPC(object):
-    """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):
-    """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):
-    """Base class for JSON views in Grok applications."""
-    interface.implements(interfaces.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)
-
-    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.annotation/trunk/src/grokcore/annotation/configure.zcml
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/configure.zcml	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/configure.zcml	2009-06-16 09:06:29 UTC (rev 101057)
@@ -1,85 +1,8 @@
 <configure
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:browser="http://namespaces.zope.org/browser"
-    xmlns:grok="http://namespaces.zope.org/grok">
+    xmlns="http://namespaces.zope.org/zope">
 
-  <include package="zope.security" file="meta.zcml" />
-  <include package="zope.i18n" file="meta.zcml" />
-  <include package="zope.securitypolicy" file="meta.zcml" />
-  <include package="zope.app.zcmlfiles" file="meta.zcml" />
-  <include package="grok" file="meta.zcml" />
-
+  <include package="grokcore.annotation" file="meta.zcml" />
   <include package="zope.annotation" />
-  <include package="zope.copypastemove" />
-  <include package="zope.contentprovider" />
-  <include package="zope.formlib" />
-  <include package="zope.i18n.locales" />
-  <include package="zope.publisher" />
-  <include package="zope.securitypolicy" />
-  <include package="zope.size" />
-  <include package="zope.traversing" />
-  <include package="zope.traversing.browser" />
-  <include package="zope.app.zcmlfiles" />
-  <include package="zope.app.authentication" />
-  <include package="zope.app.intid" />
-  <include package="zope.app.keyreference" />
-  <include package="zope.app.catalog" />
-  <include package="zope.app.renderer" />
-  <include package="zope.app.session" />
+  <include package="grokcore.component" />
 
-  <include package="grokcore.view" />
-  <include package="grokcore.viewlet" />
-  <include package="grokcore.formlib" />
-
-  <securityPolicy
-      component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
-  <adapter factory=".components.ContextTraverser" />
-  <adapter factory=".components.ContainerTraverser" />
-
-  <browser:defaultView
-      for=".interfaces.IContext"
-      name="index"
-      />
-
-  <subscriber handler=".components.addSiteHandler" />
-
-  <!-- we register a ++rest++ traversal namespace -->
-  <adapter
-      factory=".rest.rest_skin"
-      for="* zope.publisher.interfaces.browser.IHTTPRequest"
-      provides="zope.traversing.interfaces.ITraversable"
-      name="rest"
-      />
-
-  <!-- this overrides Zope 3's publication factories because they have
-       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="BROWSER"
-      factory=".publication.GrokBrowserFactory"
-      methods="GET POST HEAD"
-      mimetypes="*"
-      priority="11"
-      />
-
-  <publisher
-      name="HTTP"
-      factory=".publication.GrokHTTPFactory"
-      methods="*"
-      mimetypes="*"
-      priority="1"
-      />
-
-  <!-- need to grok this for some basic REST support -->
-  <grok:grok package=".rest" />
-
 </configure>

Deleted: grokcore.annotation/trunk/src/grokcore/annotation/directive.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/directive.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/directive.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -1,225 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006-2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Grok directives.
-
-This module defines Grok directives: the markers that users place inside
-of their classes (and sometimes in their modules, too) to direct how
-Grok registers their components.  For example, the first directive
-defined below is `local_utility`, which people programming Grok
-applications normally use like this::
-
-    class MyUtility(grok.Utility):
-        grok.local_utility()
-        ...
-
-If the set of directives in this module looks rather small, remember
-that most of the directives available in Grok actually come from the
-`grokcore` modules on which Grok depends, where they have been placed so
-that other projects can use them without having to pull in all of Grok.
-
-"""
-import grok
-from zope import interface
-from zope.interface.interfaces import IInterface
-
-import martian
-from martian import util
-from martian.error import GrokImportError
-from grokcore.view.directive import TaggedValueStoreOnce
-
-class local_utility(martian.Directive):
-    """The `grok.local_utility()` directive.
-
-    Place this directive inside of a `grok.Application` or `grok.Site`
-    subclass, and provide the name of a utility you want activated
-    inside of that site::
-
-        class MySite(grok.Site):
-            grok.local_utility(MyMammothUtility)
-            ...
-
-    This directive can be supplied several times within the same site.
-    Thanks to the presence of this directive, any time an instance of
-    your class is created in the Zope database it will have a copy of
-    the given local utility installed along with it.
-
-    This directive accepts several normal Component-registration keyword
-    arguments, like `provides` and `name`, and uses them each time it
-    registers your local utility.
-
-    If you do not supply a `provides` keyword, then Grok attempts to
-    guess a sensible default.  Its first choice is to use any
-    interface(s) that you listed with the grok.provides() directive when
-    defining your utility.  Otherwise, if your utility is a subclass of
-    `grok.localUtility`, then Grok will use any interfaces that your
-    utility supplies beyond those are supplied because of its
-    inheritance from `grok.localUtility`.  Else, as a final fallback, it
-    checks to see whether the class you are registering supplies one,
-    and only one, interface; if so, then it can register the utility
-    unambiguously as providing that one interface.
-
-    """
-    scope = martian.CLASS
-    store = martian.DICT
-
-    def factory(self, factory, provides=None, name=u'',
-                setup=None, public=False, name_in_container=None):
-        if provides is not None and not IInterface.providedBy(provides):
-            raise GrokImportError("You can only pass an interface to the "
-                                  "provides argument of %s." % self.name)
-
-        if provides is None:
-            provides = grok.provides.bind().get(factory)
-
-        if provides is None:
-            if util.check_subclass(factory, grok.LocalUtility):
-                baseInterfaces = interface.implementedBy(grok.LocalUtility)
-                utilityInterfaces = interface.implementedBy(factory)
-                provides = list(utilityInterfaces - baseInterfaces)
-
-                if len(provides) == 0 and len(list(utilityInterfaces)) > 0:
-                    raise GrokImportError(
-                        "Cannot determine which interface to use "
-                        "for utility registration of %r. "
-                        "It implements an interface that is a specialization "
-                        "of an interface implemented by grok.LocalUtility. "
-                        "Specify the interface by either using grok.provides "
-                        "on the utility or passing 'provides' to "
-                        "grok.local_utility." % factory, factory)
-            else:
-                provides = list(interface.implementedBy(factory))
-
-            util.check_implements_one_from_list(provides, factory)
-            provides = provides[0]
-
-        if (provides, name) in self.frame.f_locals.get(self.dotted_name(), {}):
-            raise GrokImportError(
-                "Conflicting local utility registration %r. "
-                "Local utilities are registered multiple "
-                "times for interface %r and name %r." %
-                (factory, provides, name), factory)
-
-        info = LocalUtilityInfo(factory, provides, name, setup, public,
-                                name_in_container)
-        return (provides, name), info
-
-
-class LocalUtilityInfo(object):
-    """The information about how to register a local utility.
-
-    An instance of this class is created for each `grok.local_utility()`
-    in a Grok application's code, to remember how the user wants their
-    local utility registered.  Later, whenever the application creates
-    new instances of the site or application for which the local utility
-    directive was supplied, this block of information is used as the
-    parameters to the creation of the local utility which is created
-    along with the new site in the Zope database.
-
-    """
-    _order = 0
-
-    def __init__(self, factory, provides, name=u'',
-                 setup=None, public=False, name_in_container=None):
-        self.factory = factory
-        self.provides = provides
-        self.name = name
-        self.setup = setup
-        self.public = public
-        self.name_in_container = name_in_container
-
-        self.order = LocalUtilityInfo._order
-        LocalUtilityInfo._order += 1
-
-    def __cmp__(self, other):
-        # LocalUtilityInfos have an inherit sort order by which the
-        # registrations take place.
-        return cmp(self.order, other.order)
-
-
-class site(martian.Directive):
-    """The `grok.site()` directive.
-
-    This directive is used when creating a `grok.Indexes` subclass, to
-    indicate the Grok site object for which the indexes should be built.
-
-    """
-    scope = martian.CLASS
-    store = martian.ONCE
-    validate = martian.validateInterfaceOrClass
-
-class permissions(martian.Directive):
-    """The `grok.permissions()` directive.
-
-    This directive is used inside of a `grok.Role` subclass to list the
-    permissions which each member of the role should always possess.
-    Note that permissions should be passed as strings, and that several
-    permissions they can simply be supplied as multiple arguments; there
-    is no need to place them inside of a tuple or list::
-
-        class MyRole(grok.Role):
-            grok.permissions('page.CreatePage', 'page.EditPage')
-            ...
-
-    """
-    scope = martian.CLASS
-    store = martian.ONCE
-    default = []
-
-    def factory(self, *args):
-        return args
-
-class traversable(martian.Directive):
-    """The `grok.traversable()` directive.
-
-    Each time this directive is used inside of a class, it designates an
-    attribute of that class which URLs should be able to traverse.  For
-    example, the declaration:
-
-        class Mammoth(grok.Model):
-            grok.traversable('thighbone')
-
-    means that if the URL `/app/mymammoth` designates a Mammoth, then
-    `/app/mymammoth/thighbone` will also be a valid URL (assuming that
-    the Mammoth instance, at runtime, indeed has an attribute by that
-    name)!  By default, the name that must be appended to the URL should
-    simply be the same as the name of the attribute; but by providing a
-    `name` keyword argument, the programmer can designate another name
-    to appear in the URL instead of the raw attribute name.
-
-    """
-    scope = martian.CLASS
-    store = martian.DICT
-
-    def factory(self, attr, name=None):
-        if name is None:
-            name = attr
-        return (name, attr)
-
-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

Deleted: grokcore.annotation/trunk/src/grokcore/annotation/index.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/index.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/index.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -1,101 +0,0 @@
-#############################################################################
-#
-# Copyright (c) 2007-2008 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Grok index definitions
-"""
-import sys
-
-from zope.interface import implements
-from zope.interface.interfaces import IMethod, IInterface
-
-from zope.app.catalog.field import FieldIndex
-from zope.app.catalog.text import TextIndex
-from zc.catalog.catalogindex import SetIndex
-
-from martian.error import GrokError, GrokImportError
-from martian.util import frame_is_class
-
-from grok.interfaces import IIndexDefinition
-
-class IndexDefinition(object):
-    """The definition of a particular index in a `grok.Indexes` class.
-
-    This base class defines the actual behavior of `grok.index.Field`
-    and the other kinds of attribute index that Grok supports.  Upon our
-    instantiation, we save every parameter that we were passed; later,
-    if an index actually needs to be created (which is typically at the
-    moment when a new `grok.Application` object is added to the Zope
-    Database), then our `setup()` method gets called.
-
-    The only parameter that is actually significant to us is `attribute`
-    which (optionally) defines the attribute we should index.  All other
-    parameters are simply passed along to the Zope index we create,
-    which interprets them as configuration details of its own.
-
-    Note that, since index creation (and thus a call to our `setup()`
-    method) currently occurs only during the creation of a new Grok
-    `Application` object in the Zope Database, the presence of this
-    declaration in Grok application code is nearly always a no-op.
-
-    """
-    implements(IIndexDefinition)
-
-    index_class = None
-
-    def __init__(self, *args, **kw):
-        frame = sys._getframe(1)
-        if not frame_is_class(frame):
-            raise GrokImportError(
-                "%r can only be instantiated on class level." % self.__class__)
-        # store any extra parameters to pass to index later
-        self._args = args
-        self._attribute = kw.pop('attribute', None)
-        self._kw = kw
-
-    def setup(self, catalog, name, context, module_info):
-        # If the user supplied attribute= when instantiating us, we
-        # allow that value to override the attribute name under which we
-        # are actually stored inside of the `grok.Indexes` instance.
-        if self._attribute is not None:
-            field_name = self._attribute
-        else:
-            field_name = name
-
-        if IInterface.providedBy(context):
-            try:
-                method = context[field_name]
-            except KeyError:
-                raise GrokError("grok.Indexes in %r refers to an attribute or "
-                                "method %r on interface %r, but this does not "
-                                "exist." % (module_info.getModule(),
-                                            field_name, context), None)
-            call = IMethod.providedBy(method)
-        else:
-            call = callable(getattr(context, field_name, None))
-            context = None # no interface lookup
-        catalog[name] = self.index_class(field_name=field_name,
-                                         interface=context,
-                                         field_callable=call,
-                                         *self._args, **self._kw)
-
-class Field(IndexDefinition):
-    """A `grok.Indexes` index that matches against an entire field."""
-    index_class = FieldIndex
-
-class Text(IndexDefinition):
-    """A `grok.Indexes` index supporting full-text searches of a field."""
-    index_class = TextIndex
-
-class Set(IndexDefinition):
-    """A `grok.Indexes` index supporting keyword searches of a field."""
-    index_class = SetIndex

Modified: grokcore.annotation/trunk/src/grokcore/annotation/interfaces.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/interfaces.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/interfaces.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -14,214 +14,7 @@
 """Grok interfaces
 """
 from zope import interface
-from zope.interface.interfaces import IInterface
-from zope.publisher.interfaces.http import IHTTPRequest
-from zope.app.container.interfaces import IContainer as IContainerBase
 
-# Expose interfaces from grokcore.* packages as well:
-import grokcore.component.interfaces
-import grokcore.formlib.interfaces
-import grokcore.security.interfaces
-import grokcore.view.interfaces
-import grokcore.viewlet.interfaces
-
-from grokcore.component.interfaces import IContext
-from grokcore.component.interfaces import IGrokErrors
-
-
-class IGrokBaseClasses(grokcore.component.interfaces.IBaseClasses,
-                       grokcore.security.interfaces.IBaseClasses,
-                       grokcore.view.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.")
-    Site = interface.Attribute("Mixin class for sites.")
-    Application = interface.Attribute("Base class for applications.")
+class IGrokcoreAnnotationAPI(interface.Interface):
     Annotation = interface.Attribute("Base class for persistent annotations.")
-    LocalUtility = interface.Attribute("Base class for local utilities.")
-    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.")
-    Role = interface.Attribute("Base class for roles.")
 
-
-class IGrokDirectives(grokcore.component.interfaces.IDirectives,
-                      grokcore.security.interfaces.IDirectives,
-                      grokcore.view.interfaces.IDirectives):
-
-    def local_utility(factory, provides=None, name=u'',
-                      setup=None, public=False, name_in_container=None):
-        """Register a local utility.
-
-        factory - the factory that creates the local utility
-        provides - the interface the utility should be looked up with
-        name - the name of the utility
-        setup - a callable that receives the utility as its single argument,
-                it is called after the utility has been created and stored
-        public - if False, the utility will be stored below ++etc++site
-                 if True, the utility will be stored directly in the site.
-                 The site should in this case be a container.
-        name_in_container - the name to use for storing the utility
-        """
-
-    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("")
-
-class IGrokAPI(grokcore.security.interfaces.IGrokcoreSecurityAPI,
-               grokcore.view.interfaces.IGrokcoreViewAPI,
-               grokcore.viewlet.interfaces.IGrokcoreViewletAPI,
-               grokcore.formlib.interfaces.IGrokcoreFormlibAPI,
-               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):
-    context = interface.Attribute("Object that the REST handler presents.")
-
-    request = interface.Attribute("Request that REST handler was looked"
-                                  "up with.")
-
-    body = interface.Attribute(
-        """The text of the request body.""")
-
-class IApplication(interface.Interface):
-    """Marker-interface for grok application factories.
-
-    Used to register applications as utilities to look them up and
-    provide a list of grokked applications.
-    """
-
-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.
-
-    Base Interfaces for defining REST-layers.
-    """
-
-class IRESTSkinType(IInterface):
-    """Skin type for REST requests.
-    """
-
-class IContainer(IContext, IContainerBase):
-    """A Grok container.
-    """
-
-class IGrokSecurityView(interface.Interface):
-    """A view treated special by the Grok publisher.
-
-    Views that provide this interface are treated more generously by
-    the Grok publisher, as they are allowed to use attributes, which
-    are not covered by permission setttings.
-
-    `grok.Permission` and `grok.require` settings however, will be
-    applied to such views.
-    """

Modified: grokcore.annotation/trunk/src/grokcore/annotation/meta.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/meta.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/meta.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -11,57 +11,22 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Grokkers for Grok-configured components.
-
-This `meta` module contains the actual grokker mechanisms for which the
-Grok web framework is named.  A directive in the adjacent `meta.zcml`
-file directs the `martian` library to scan this file, where it discovers
-and registers the grokkers you see below.  The grokkers are then active
-and available as `martian` recursively examines the packages and modules
-of a Grok-based web application.
-
+"""Grokkers for Grokcore Annotation component.
 """
-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.http import IHTTPRequest
 
-from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
-from zope.securitypolicy.interfaces import IRole
-from zope.securitypolicy.rolepermission import rolePermissionManager
-
 from zope.annotation.interfaces import IAnnotations
 
-from zope.app.publisher.xmlrpc import MethodPublisher
-from zope.app.container.interfaces import IContainer
-from zope.app.container.interfaces import INameChooser
 from zope.app.container.contained import contained
 
-from zope.app.intid import IntIds
-from zope.app.intid.interfaces import IIntIds
-from zope.app.catalog.catalog import Catalog
-from zope.app.catalog.interfaces import ICatalog
-
-from zope.exceptions.interfaces import DuplicationError
-
 import martian
-from martian.error import GrokError
 from martian import util
 
-import grok
-from grok import components
-from grok.util import make_checker
-from grok.interfaces import IRESTSkinType
+import grokcore.annotation
 
-from grokcore.security.meta import PermissionGrokker
 
-from grokcore.view.meta.views import default_fallback_to_name
-
-
 def default_annotation_provides(factory, module, **data):
-    base_interfaces = interface.implementedBy(grok.Annotation)
+    base_interfaces = interface.implementedBy(grokcore.annotation.Annotation)
     factory_interfaces = interface.implementedBy(factory)
     real_interfaces = list(factory_interfaces - base_interfaces)
     util.check_implements_one_from_list(real_interfaces, factory)
@@ -71,328 +36,16 @@
     return factory.__module__ + '.' + factory.__name__
 
 
-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.
-
+class AnnotationGrokker(martian.ClassGrokker):
+    """Grokker for components subclassed from `grok.Annotation`.
     """
-    martian.component(grok.XMLRPC)
-    martian.directive(grok.context)
-    martian.directive(grok.require, name='permission')
+    martian.component(grokcore.annotation.Annotation)
+    martian.directive(grokcore.annotation.context, name='adapter_context')
+    martian.directive(grokcore.annotation.provides,
+                      get_default=default_annotation_provides)
+    martian.directive(grokcore.annotation.name,
+                      get_default=default_annotation_name)
 
-    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.
-
-    When an application defines a `grok.REST` 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 REST adapter for the context, and the other
-    to prepare a security check for the adapter.
-
-    This results in several registered views, typically with names like
-    `GET`, `PUT`, and `POST` - one for each method that the `grok.REST`
-    subclass defines.
-
-    """
-    martian.component(grok.REST)
-    martian.directive(grok.context)
-    martian.directive(grok.layer, default=grok.IRESTLayer)
-    martian.directive(grok.require, name='permission')
-
-    def execute(self, factory, method, config, permission, context,
-                layer, **kw):
-        name = method.__name__
-
-        method_view = type(
-            factory.__name__, (factory,),
-            {'__call__': method }
-            )
-
-        adapts = (context, layer)
-        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
-
-
-_restskin_not_used = object()
-
-class RestskinInterfaceDirectiveGrokker(martian.InstanceGrokker):
-    """Grokker for interfaces providing the `grok.restskin()` directive.
-
-    Applications create REST skins by subclassing `grok.IRESTLayer`
-    and providing the subclass with a `grok.restskin()` directive giving
-    the prefix string which distinguishes that REST layers from others.
-    This grokker registers those skins.
-
-    """
-    martian.component(InterfaceClass)
-
-    def grok(self, name, interface, module_info, config, **kw):
-        # This `InstanceGrokker` will be called for every instance of
-        # `InterfaceClass` - that is, for every interface defined in an
-        # 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)
-        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):
-            # For REST layers it is required to extend IRESTLayer.
-            raise GrokError(
-                "The grok.restskin() directive is used on interface %r. "
-                "However, %r does not extend IRESTLayer which is "
-                "required for interfaces that are used as layers and are to "
-                "be registered as a restskin."
-                % (interface.__identifier__, interface.__identifier__),
-                interface
-                )
-        config.action(
-            discriminator=('restprotocol', restskin),
-            callable=zope.component.interface.provideInterface,
-            args=(restskin, interface, IRESTSkinType)
-            )
-        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)
-    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)
-    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
-
-
-class SiteGrokker(martian.ClassGrokker):
-    """Grokker for subclasses of `grok.Site`."""
-    martian.component(grok.Site)
-    martian.priority(500)
-    martian.directive(grok.local_utility, name='infos')
-
-    def execute(self, factory, config, infos, **kw):
-        if not infos:
-            return False
-
-        infos = infos.values()
-        for info in infos:
-            if info.public and not IContainer.implementedBy(factory):
-                raise GrokError(
-                    "Cannot set public to True with grok.local_utility as "
-                    "the site (%r) is not a container." %
-                    factory, factory)
-
-        # Store the list of info objects in their "natural" order on the
-        # site class. They will be picked up by a subscriber doing the
-        # actual registrations in definition order.
-        factory.__grok_utilities_to_install__ = sorted(infos)
-        adapts = (factory, grok.IObjectAddedEvent)
-
-        config.action(
-            discriminator=None,
-            callable=component.provideHandler,
-            args=(localUtilityRegistrationSubscriber, adapts),
-            )
-        return True
-
-
-def localUtilityRegistrationSubscriber(site, event):
-    """A subscriber that fires to set up local utilities.
-    """
-    installed = getattr(site, '__grok_utilities_installed__', False)
-    if installed:
-        return
-
-    for info in getattr(site.__class__, '__grok_utilities_to_install__', []):
-        setupUtility(site, info.factory(), info.provides, name=info.name,
-                     name_in_container=info.name_in_container,
-                     public=info.public, setup=info.setup)
-
-    # we are done. If this subscriber gets fired again, we therefore
-    # do not register utilities anymore
-    site.__grok_utilities_installed__ = True
-
-
-def setupUtility(site, utility, provides, name=u'',
-                 name_in_container=None, public=False, setup=None):
-    """Set up a utility in a site.
-
-    site - the site to set up the utility in
-    utility - the utility to set up
-    provides - the interface the utility should be registered with
-    name - the name the utility should be registered under, default
-      the empty string (no name)
-    name_in_container - if given it will be used to add the utility
-      object to its container. Otherwise a name will be made up
-    public - if False, the utility will be stored in the site manager. If
-      True, the utility will be storedin the site (it is assumed the
-      site is a container)
-    setup - if not None, it will be called with the utility as its first
-       argument. This function can then be used to further set up the
-       utility.
-    """
-    site_manager = site.getSiteManager()
-
-    if not public:
-        container = site_manager
-    else:
-        container = site
-
-    if name_in_container is None:
-        name_in_container = INameChooser(container).chooseName(
-            utility.__class__.__name__, utility)
-    container[name_in_container] = utility
-
-    if setup is not None:
-        setup(utility)
-
-    site_manager.registerUtility(utility, provided=provides,
-                                 name=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.
-        role = factory(unicode(name), unicode(title), unicode(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 AnnotationGrokker(martian.ClassGrokker):
-    """Grokker for components subclassed from `grok.Annotation`."""
-    martian.component(grok.Annotation)
-    martian.directive(grok.context, name='adapter_context')
-    martian.directive(grok.provides, get_default=default_annotation_provides)
-    martian.directive(grok.name, get_default=default_annotation_name)
-
     def execute(self, factory, config, adapter_context, provides, name, **kw):
         @component.adapter(adapter_context)
         @interface.implementer(provides)
@@ -419,114 +72,3 @@
         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(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(site, intids, IIntIds)
-        return intids
-

Modified: grokcore.annotation/trunk/src/grokcore/annotation/meta.zcml
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/meta.zcml	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/meta.zcml	2009-06-16 09:06:29 UTC (rev 101057)
@@ -3,14 +3,9 @@
     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" />
+
   <grok:grok package=".meta" />
 
 </configure>

Deleted: grokcore.annotation/trunk/src/grokcore/annotation/publication.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/publication.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/publication.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -1,178 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Grok publication factories and classes.
-
-These factories, and the publication classes they return, make Grok
-security different from the way that security normal operates during
-Zope publication.  Instead of security proxies being wrapped around
-every object generated during traversal, and then wrapped around the
-final object before it is viewed, only a single security check is done
-when Grok is in charge: a check to see whether the view selected at the
-end of the traversal process is, in fact, permitted to display the
-object.
-
-"""
-from grok.rest import GrokMethodNotAllowed
-
-from zope import component
-from zope.security.proxy import removeSecurityProxy
-from zope.security.checker import selectChecker
-from zope.publisher.publish import mapply
-
-from zope.publisher.interfaces.browser import IBrowserView
-
-from zope.app.publication.http import BaseHTTPPublication, HTTPPublication
-from zope.app.publication.browser import BrowserPublication
-from zope.app.publication.requestpublicationfactories import \
-     BrowserFactory, XMLRPCFactory, HTTPFactory
-from zope.app.http.interfaces import IHTTPException
-
-from grok.interfaces import IGrokSecurityView
-
-class ZopePublicationSansProxy(object):
-    """Grok mixin that makes a publisher remove security proxies.
-
-    This mixin overrides three methods from the `IPublication`
-    interface (defined in `zope.publisher.interfaces`) to alter their
-    security behavior.  The normal Zope machinery wraps a security
-    proxy around the application object returned by
-    `getApplication()`, and around each of the objects returned as
-    `traverseName()` is then called for each URL component.  The
-    versions here strip the security proxy off instead, returning the
-    bare object (unless the object is a non-Grok view, in which case
-    we leave the proxy installed for important security
-    reasons).  Non-Grok views however, are handled like Grok views, if
-    they provide `grok.interfaces.IGrokSecurityView`.
-
-    Finally, when `callObject()` is asked to render
-    the view, we quickly re-install a security proxy on the object, make
-    sure that the current user is indeed allowed to invoke `__call__()`,
-    then pass the bare object to the rendering machinery.
-
-    The result is that, in place of the elaborate series of security
-    checks made during the processing of a normal Zope request, Grok
-    makes only a single security check: to see if the view can be
-    permissibly rendered or not.
-
-    """
-    def getApplication(self, request):
-        result = super(ZopePublicationSansProxy, self).getApplication(request)
-        return removeSecurityProxy(result)
-
-    def traverseName(self, request, ob, name):
-        result = super(ZopePublicationSansProxy, self).traverseName(
-            request, ob, name)
-        bare_result = removeSecurityProxy(result)
-        if IBrowserView.providedBy(bare_result):
-            if IGrokSecurityView.providedBy(bare_result):
-                return bare_result
-            else:
-                return result
-        else:
-            return bare_result
-
-    def callObject(self, request, ob):
-        checker = selectChecker(ob)
-        if checker is not None:
-            checker.check(ob, '__call__')
-        return super(ZopePublicationSansProxy, self).callObject(request, ob)
-
-
-class GrokBrowserPublication(ZopePublicationSansProxy, BrowserPublication):
-    """Combines `BrowserPublication` with the Grok sans-proxy mixin.
-
-    In addition to the three methods that are overridden by the
-    `ZopePublicationSansProxy`, this class overrides a fourth: the
-    `getDefaultTraversal()` method, which strips the security proxy from
-    the object being returned by the normal method.
-
-    """
-    def getDefaultTraversal(self, request, ob):
-        obj, path = super(GrokBrowserPublication, self).getDefaultTraversal(
-            request, ob)
-        return removeSecurityProxy(obj), path
-
-class GrokBrowserFactory(BrowserFactory):
-    """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 browser requests.
-    - The publication class that Grok uses to publish to a browser.
-
-    """
-    def __call__(self):
-        request, publication = super(GrokBrowserFactory, self).__call__()
-        return request, GrokBrowserPublication
-
-
-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.
-
-    Because `HTTPPublication` provides its own, special `callObject()`
-    implementation, this subclass does the same, providing what is
-    basically the same call (you can verify, in fact, that most of its
-    lines were copied directly from the superclass's version) but with a
-    few extra lines added so that - as with the simpler `callObject()`
-    method in `ZopePublicationSansProxy` - it quickly places a security
-    proxy around the object, makes sure that this HTTP method is
-    permitted, and finally passes the bare object to the view that will
-    render it.
-
-    """
-    def callObject(self, request, ob):
-        orig = ob
-        if not IHTTPException.providedBy(ob):
-            ob = component.queryMultiAdapter((ob, request),
-                                            name=request.method)
-            checker = selectChecker(ob)
-            if checker is not None:
-                checker.check(ob, '__call__')
-            ob = getattr(ob, request.method, None)
-            if ob is None:
-                raise GrokMethodNotAllowed(orig, request)
-        return mapply(ob, request.getPositionalArguments(), request)
-
-class GrokHTTPFactory(HTTPFactory):
-    """Returns the classes Grok uses for HTTP 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 HTTP requests.
-    - The publication class that Grok uses to publish to HTTP.
-
-    """
-    def __call__(self):
-        request, publication = super(GrokHTTPFactory, self).__call__()
-        return request, GrokHTTPPublication

Deleted: grokcore.annotation/trunk/src/grokcore/annotation/rest.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/rest.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/rest.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -1,108 +0,0 @@
-"""Default REST view for Grok.
-
-The views provided by this module get invoked when an object receives an
-HTTP request in a REST skin for which no more-specific REST behavior has
-been defined.  These all return the HTTP response Method Not Allowed.
-
-"""
-import grok
-from grok.interfaces import IRESTSkinType
-
-from zope import component
-from zope.component.interfaces import ComponentLookupError
-from zope.traversing.interfaces import TraversalError
-from zope.traversing.namespace import view
-from zope.interface import Interface
-from zope.publisher.interfaces.http import IHTTPRequest
-from zope.app.publication.http import MethodNotAllowed
-from zope.publisher.browser import applySkin
-
-
-class GrokMethodNotAllowed(MethodNotAllowed):
-    """Exception indicating that an attempted REST method is not allowed."""
-
-
-class MethodNotAllowedView(grok.MultiAdapter):
-    """View rendering a REST GrokMethodNotAllowed exception over HTTP.
-
-    Not only does this view render the REST error as an HTTP status of
-    405 (Method Not Allowed) and a simple text message as the document
-    body, but also offers an ``Allow:`` HTTP header listing any methods
-    that can, in fact, succeed.  It constructs this list by testing the
-    current object to see which methods it supports; if none of the
-    standard methods succeed, then the ``Allow:`` header is still
-    provided, but its value will be empty.
-
-    """
-    grok.adapts(GrokMethodNotAllowed, IHTTPRequest)
-    grok.name('index.html')
-    grok.implements(Interface)
-
-    def __init__(self, error, request):
-        self.error = error
-        self.request = request
-        self.allow = self._getAllow()
-
-    def _getAllow(self):
-        allow = []
-        # List methods here in the same order that they should appear in
-        # the "Allow:" header.
-        for method in 'DELETE', 'GET', 'POST', 'PUT':
-            view = component.queryMultiAdapter(
-                (self.error.object, self.error.request),
-                name=method)
-            if view is not None:
-                is_not_allowed = getattr(view, 'is_not_allowed', False)
-                if not is_not_allowed:
-                    allow.append(method)
-        return allow
-
-    def __call__(self):
-        self.request.response.setHeader('Allow', ', '.join(self.allow))
-        self.request.response.setStatus(405)
-        return 'Method Not Allowed'
-
-
-class rest_skin(view):
-    """A rest skin.
-
-    This used to be supported by zope.traversing but the change was
-    backed out.  We need it for our REST support.
-
-    """
-    def traverse(self, name, ignored):
-        self.request.shiftNameToApplication()
-        try:
-            skin = component.getUtility(IRESTSkinType, name)
-        except ComponentLookupError:
-            raise TraversalError("++rest++%s" % name)
-        applySkin(self.request, skin)
-        return self.context
-
-
-class NotAllowedREST(grok.REST):
-    """Default REST view, whose methods all raise Not Allowed errors.
-
-    By binding itself to ``Interface``, this becomes the most general
-    available REST view, and will be called into service for objects
-    that have not had more specific REST views registered.  This means
-    that such objects can at least return attractive refusals when
-    clients attempt to assail them with unwanted HTTP methods.
-
-    """
-    grok.layer(grok.IRESTLayer)
-    grok.context(Interface)
-
-    is_not_allowed = True
-
-    def GET(self):
-        raise GrokMethodNotAllowed(self.context, self.request)
-
-    def POST(self):
-        raise GrokMethodNotAllowed(self.context, self.request)
-
-    def PUT(self):
-        raise GrokMethodNotAllowed(self.context, self.request)
-
-    def DELETE(self):
-        raise GrokMethodNotAllowed(self.context, self.request)

Modified: grokcore.annotation/trunk/src/grokcore/annotation/testing.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/testing.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/testing.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -42,12 +42,7 @@
 def grok(module_name):
     config = ConfigurationMachine()
     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('grok.meta', config)
+    zcml.do_grok('grokcore.annotation.meta', config)
     zcml.do_grok(module_name, config)
     config.execute_actions()
 

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/annotation.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/annotation.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/annotation.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -21,7 +21,7 @@
 
 """
 
-import grok
+import grokcore.annotation as grok
 from zope import interface
 from BTrees.OOBTree import OOTreeSet
 
@@ -39,7 +39,7 @@
 class Branding(grok.Annotation):
     grok.implements(IBranding)
 
-    def __init__(self): 
+    def __init__(self):
         self._brands = OOTreeSet()
 
     def addBrand(self, brand):

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsmany.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsmany.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsmany.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -11,7 +11,7 @@
   which one to use).
 """
 
-import grok
+import grokcore.annotation as grok
 from zope import interface
 
 class Mammoth(grok.Model):

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsnone.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsnone.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/implementsnone.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -11,7 +11,7 @@
 
 """
 
-import grok
+import grokcore.annotation as grok
 
 class Mammoth(grok.Model):
     pass

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/name.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/name.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/name.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -28,7 +28,7 @@
 
 """
 
-import grok
+import grokcore.annotation as grok
 from zope import interface
 from BTrees.OOBTree import OOTreeSet
 

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/provides.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/provides.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/annotation/provides.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -19,7 +19,7 @@
 
 """
 
-import grok
+import grokcore.annotation as grok
 from zope import interface
 from BTrees.OOBTree import OOTreeSet
 

Modified: grokcore.annotation/trunk/src/grokcore/annotation/tests/test_grok.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/tests/test_grok.py	2009-06-16 09:05:22 UTC (rev 101056)
+++ grokcore.annotation/trunk/src/grokcore/annotation/tests/test_grok.py	2009-06-16 09:06:29 UTC (rev 101057)
@@ -29,7 +29,7 @@
         if filename == '__init__.py':
             continue
 
-        dottedname = 'grok.tests.%s.%s' % (name, filename[:-3])
+        dottedname = 'grokcore.annotation.tests.%s.%s' % (name, filename[:-3])
         test = doctest.DocTestSuite(dottedname,
                                     setUp=setUpZope,
                                     tearDown=cleanUpZope,
@@ -42,11 +42,7 @@
 
 def test_suite():
     suite = unittest.TestSuite()
-    for name in ['adapter', 'error', 'event', 'security', 'catalog',
-                 'zcml', 'utility', 'xmlrpc', 'json', 'container',
-                 'traversal', 'grokker', 'directive',
-                 'baseclass', 'annotation', 'application',
-                 'viewlet', 'testsetup', 'conflict']:
+    for name in ['annotation',]:
         suite.addTest(suiteFromPackage(name))
     return suite
 



More information about the Checkins mailing list