[Checkins] SVN: five.grok/trunk/src/five/grok/ Missing stuff from the branch merge.

Lennart Regebro regebro at gmail.com
Fri Jul 18 11:30:39 EDT 2008


Log message for revision 88526:
  Missing stuff from the branch merge.
  

Changed:
  U   five.grok/trunk/src/five/grok/__init__.py
  U   five.grok/trunk/src/five/grok/components.py
  U   five.grok/trunk/src/five/grok/configure.zcml
  D   five.grok/trunk/src/five/grok/directive.py
  U   five.grok/trunk/src/five/grok/ftesting.zcml
  D   five.grok/trunk/src/five/grok/interfaces.py
  U   five.grok/trunk/src/five/grok/meta.py
  D   five.grok/trunk/src/five/grok/templatereg.py
  U   five.grok/trunk/src/five/grok/testing.py
  D   five.grok/trunk/src/five/grok/util.py

-=-
Modified: five.grok/trunk/src/five/grok/__init__.py
===================================================================
--- five.grok/trunk/src/five/grok/__init__.py	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/__init__.py	2008-07-18 15:30:38 UTC (rev 88526)
@@ -5,10 +5,7 @@
 
 from grokcore.component import Adapter, MultiAdapter, GlobalUtility
 from grokcore.component import context, name, provides, subscribe
-from grokcore.view.components import PageTemplate
+from grokcore.view import PageTemplate, IGrokLayer, Skin
+from grokcore.view import template, require, layer, templatedir
 
-from five.grok.components import View, Model, IGrokLayer, Skin
-from five.grok.directive import require, layer, template, templatedir
-
-# I don't know why this is necessary:
-from five.grok import testing
\ No newline at end of file
+from five.grok.components import View, Model

Modified: five.grok/trunk/src/five/grok/components.py
===================================================================
--- five.grok/trunk/src/five/grok/components.py	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/components.py	2008-07-18 15:30:38 UTC (rev 88526)
@@ -1,35 +1,18 @@
-import sys, os
-import warnings
-
-import martian
 from zope import interface
-from zope import component
 from zope.annotation.interfaces import IAttributeAnnotatable
-from zope.app.pagetemplate.engine import TrustedAppPT
-from zope.pagetemplate import pagetemplate, pagetemplatefile
 
-from zope.publisher.publish import mapply
+from grokcore.component.interfaces import IContext
 
 import Acquisition
 from OFS.SimpleItem import SimpleItem
-from five.grok import interfaces
 
-from zope.app.container.contained import Contained
-import persistent
-
 from grokcore.view import GrokView
 
 class Model(SimpleItem):
     # XXX Inheritance order is important here. If we reverse this,
     # then containers can't be models anymore because no unambigous MRO
     # can be established.
-    interface.implements(IAttributeAnnotatable, interfaces.IContext)
+    interface.implements(IAttributeAnnotatable, IContext)
 
 class View(GrokView, Acquisition.Implicit):
-    pass
-
-class IGrokLayer(interface.Interface):
-    pass
-
-class Skin(object):
-    pass
+    pass
\ No newline at end of file

Modified: five.grok/trunk/src/five/grok/configure.zcml
===================================================================
--- five.grok/trunk/src/five/grok/configure.zcml	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/configure.zcml	2008-07-18 15:30:38 UTC (rev 88526)
@@ -7,7 +7,7 @@
   <grok:grok package=".meta" />
 
   <browser:defaultView
-      for=".interfaces.IContext"
+      for="grokcore.component.interfaces.IContext"
       name="index"
       />
 
@@ -16,7 +16,6 @@
     title="View"
     />
 
-  <include package="zope.app.basicskin" />
-  <include package="zope.app.rotterdam" />
+  <include package="grokcore.view" file="meta.zcml" />
   
 </configure>

Deleted: five.grok/trunk/src/five/grok/directive.py
===================================================================
--- five.grok/trunk/src/five/grok/directive.py	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/directive.py	2008-07-18 15:30:38 UTC (rev 88526)
@@ -1,50 +0,0 @@
-import martian
-from martian.directive import StoreMultipleTimes
-
-class RequireDirectiveStore(StoreMultipleTimes):
-
-    def get(self, directive, component, default):
-        permissions = getattr(component, directive.dotted_name(), default)
-        if (permissions is default) or not permissions:
-            return default
-        if len(permissions) > 1:
-            raise GrokError('grok.require was called multiple times in '
-                            '%r. It may only be set once for a class.'
-                            % component, component)
-        return permissions[0]
-
-    def pop(self, locals_, directive):
-        return locals_[directive.dotted_name()].pop()
-
-
-class require(martian.Directive):
-    scope = martian.CLASS
-    store = RequireDirectiveStore()
-    validate = martian.validateText
-
-    def __call__(self, func):
-        # grok.require can be used both as a class-level directive and
-        # as a decorator for methods.  Therefore we return a decorator
-        # here, which may be used for methods, or simply ignored when
-        # used as a directive.
-        frame = sys._getframe(1)
-        permission = self.store.pop(frame.f_locals, self)
-        self.set(func, [permission])
-        return func
-
-    
-class layer(martian.Directive):
-    scope = martian.CLASS_OR_MODULE
-    store = martian.ONCE
-    validate = martian.validateInterfaceOrClass
-
-class template(martian.Directive):
-    scope = martian.CLASS
-    store = martian.ONCE
-    validate = martian.validateText
-
-class templatedir(martian.Directive):
-    scope = martian.MODULE
-    store = martian.ONCE
-    validate = martian.validateText
-    
\ No newline at end of file

Modified: five.grok/trunk/src/five/grok/ftesting.zcml
===================================================================
--- five.grok/trunk/src/five/grok/ftesting.zcml	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/ftesting.zcml	2008-07-18 15:30:38 UTC (rev 88526)
@@ -9,4 +9,8 @@
 
   <!-- And also grok all the ftests /-->
   <grok:grok package="five.grok.ftests" />
+  
+  <include package="zope.app.basicskin" />
+  <include package="zope.app.rotterdam" />
+
 </configure>

Deleted: five.grok/trunk/src/five/grok/interfaces.py
===================================================================
--- five.grok/trunk/src/five/grok/interfaces.py	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/interfaces.py	2008-07-18 15:30:38 UTC (rev 88526)
@@ -1,525 +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 interfaces
-"""
-from zope import interface, schema
-from zope.publisher.interfaces.browser import IBrowserPage, IBrowserView
-from zope.formlib.interfaces import reConstraint
-from zope.interface.interfaces import IInterface
-from zope.viewlet.interfaces import IViewletManager as IViewletManagerBase
-from zope.app.container.interfaces import IContainer as IContainerBase
-
-from grokcore.component.interfaces import IContext
-
-class IGrokBaseClasses(interface.Interface):
-    ClassGrokker = interface.Attribute("Base class to define a class "
-                                       "grokker.")
-    InstanceGrokker = interface.Attribute("Base class to define an "
-                                          "instance grokker.")
-    ModuleGrokker = interface.Attribute("Base class to define a "
-                                        "module grokker.")
-    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.")
-    Adapter = interface.Attribute("Base class for adapters.")
-    MultiAdapter = interface.Attribute("Base class for multi-adapters.")
-    Annotation = interface.Attribute("Base class for persistent annotations.")
-    GlobalUtility = interface.Attribute("Base class for global utilities.")
-    LocalUtility = interface.Attribute("Base class for local utilities.")
-    View = interface.Attribute("Base class for browser views.")
-    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.")
-    Form = interface.Attribute("Base class for forms.")
-    AddForm = interface.Attribute("Base class for add forms.")
-    EditForm = interface.Attribute("Base class for edit forms.")
-    DisplayForm = interface.Attribute("Base class for display forms.")
-    Indexes = interface.Attribute("Base class for catalog index definitions.")
-    Layer = interface.Attribute("Base interface for layers.")
-    Skin = interface.Attribute("Base class for skin.")
-    ViewletManager = interface.Attribute("Base class for viewletmanager.")
-    Viewlet = interface.Attribute("Base class for viewlet.")
-    Permission = interface.Attribute("Base class for permissions.")
-    Role = interface.Attribute("Base class for roles.")
-    Public = interface.Attribute("Marker for explicitly not requiring a permission.")
-
-
-class IGrokErrors(interface.Interface):
-
-    def GrokError(message, component):
-        """Error indicating that a problem occurrend during the
-        grokking of a module (at "grok time")."""
-
-    def GrokImportError(*args):
-        """Error indicating a problem at import time."""
-
-
-class IGrokDirectives(interface.Interface):
-
-    def implements(*interfaces):
-        """Declare that a class implements the given interfaces."""
-
-    def adapts(*classes_or_interfaces):
-        """Declare that a class adapts objects of the given classes or
-        interfaces."""
-
-    def context(class_or_interface):
-        """Declare the context for views, adapters, etc.
-
-        This directive can be used on module and class level.  When
-        used on module level, it will set the context for all views,
-        adapters, etc. in that module.  When used on class level, it
-        will set the context for that particular class."""
-
-    def name(name):
-        """Declare the name of a view or adapter/multi-adapter.
-
-        This directive can only be used on class level."""
-
-    def layer(layer):
-        """Declare the layer for the view.
-
-        This directive acts as a contraint on the 'request' of
-        grok.View. This directive can only be used on class level."""
-
-    def skin(skin):
-        """Declare this layer as a named skin.
-
-        This directive can only be used on class level."""
-
-    def template(template):
-        """Declare the template name for a view.
-
-        This directive can only be used on class level."""
-
-    def templatedir(directory):
-        """Declare a directory to be searched for templates.
-
-        By default, grok will take the name of the module as the name
-        of the directory.  This can be overridden using
-        ``templatedir``."""
-
-    def provides(interface):
-        """Explicitly specify with which interface a component will be
-        looked up."""
-
-    def baseclass():
-        """Mark this class as a base class.
-
-        This means it won't be grokked, though if it's a possible context,
-        it can still serve as a context.
-        """
-
-    def global_utility(factory, provides=None, name=u''):
-        """Register a global utility.
-
-        factory - the factory that creates the global utility
-        provides - the interface the utility should be looked up with
-        name - the name of the utility
-        """
-
-    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 require(permission):
-        """Protect a view class or an XMLRPC method with ``permision``.
-
-        ``permission`` must already be defined, e.g. using
-        grok.Permission.
-
-        grok.require can be used as a class-level directive or as a
-        method decorator."""
-
-    def site(class_or_interface):
-        """Specifies the site that an indexes definition is for.
-
-        It can only be used inside grok.Indexes subclasses.
-        """
-
-    def order(value=None):
-        """Control the ordering of components.
-
-        If the value is specified, the order will be determined by sorting on
-        it.
-        If no value is specified, the order will be determined by definition
-        order within the module.
-        If the directive is absent, the order will be determined by class name.
-        (unfortunately our preferred default behavior on absence which would
-        be like grok.order() without argument is hard to implement in Python)
-
-        Inter-module order is by dotted name of the module the
-        components are in; unless an explicit argument is specified to
-        ``grok.order()``, components are grouped by module.
-
-        The function grok.util.sort_components can be used to sort
-        components according to these rules.
-        """
-
-
-class IGrokDecorators(interface.Interface):
-
-    def subscribe(*classes_or_interfaces):
-        """Declare that a function subscribes to an event or a
-        combination of objects and events."""
-
-    def action(label, **options):
-        """Decorator that defines an action factory based on a form
-        method. The method receives the form data as keyword
-        parameters."""
-
-
-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("")
-
-
-class IGrokAPI(IGrokBaseClasses, IGrokDirectives, IGrokDecorators,
-               IGrokEvents, IGrokErrors):
-
-    def grok(dotted_name):
-        """Grok a module or package specified by ``dotted_name``."""
-
-    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.
-        """
-
-    def url(request, obj, name=None, data=None):
-        """Generate the URL to an object with optional name attached.
-        An optional argument 'data' can be a dictionary that is converted
-        into a query string appended to the URL.
-        """
-
-    def notify(event):
-        """Send ``event`` to event subscribers."""
-
-    def getSite():
-        """Get the current site."""
-
-    def PageTemplate(template):
-        """Create a Grok PageTemplate object from ``template`` source
-        text.  This can be used for inline PageTemplates."""
-
-    def PageTemplateFile(filename):
-        """Create a Grok PageTemplate object from a file specified by
-        ``filename``.  It will be treated like an inline template
-        created with ``PageTemplate``."""
-
-    def Fields(*args, **kw):
-        """Return a list of formlib fields based on interfaces and/or schema
-        fields."""
-
-    def AutoFields(context):
-        """Return a list of fields for context autogenerated by grok.
-        """
-
-    def action(label, actions=None, **options):
-        """grok-specific action decorator.
-        """
-
-    IRESTSkinType = interface.Attribute('The REST skin type')
-
-class IGrokView(IBrowserPage, IBrowserView):
-    """Grok views all provide this interface."""
-
-    context = interface.Attribute('context', "Object that the view presents.")
-
-    request = interface.Attribute('request', "Request that the view was looked"
-                                  "up with.")
-
-    response = interface.Attribute('response', "Response object that is "
-                                   "associated with the current request.")
-
-    static = interface.Attribute('static', "Directory resource containing "
-                                 "the static files of the view's package.")
-
-    def redirect(url):
-       """Redirect to given URL"""
-
-    def url(obj=None, name=None, data=None):
-        """Construct URL.
-
-        If no arguments given, construct URL to view itself.
-
-        If only obj argument is given, construct URL to obj.
-
-        If only name is given as the first argument, construct URL
-        to context/name.
-
-        If both object and name arguments are supplied, construct
-        URL to obj/name.
-
-        Optionally pass a 'data' keyword argument which gets added to the URL
-        as a cgi query string.
-        """
-
-    def default_namespace():
-        """Returns a dictionary of namespaces that the template
-        implementation expects to always be available.
-
-        This method is *not* intended to be overridden by application
-        developers.
-        """
-
-    def namespace():
-        """Returns a dictionary that is injected in the template
-        namespace in addition to the default namespace.
-
-        This method *is* intended to be overridden by the application
-        developer.
-        """
-
-    def update(**kw):
-        """This method is meant to be implemented by grok.View
-        subclasses.  It will be called *before* the view's associated
-        template is rendered and can be used to pre-compute values
-        for the template.
-
-        update() can take arbitrary keyword parameters which will be
-        filled in from the request (in that case they *must* be
-        present in the request)."""
-
-    def render(**kw):
-        """A view can either be rendered by an associated template, or
-        it can implement this method to render itself from Python.
-        This is useful if the view's output isn't XML/HTML but
-        something computed in Python (plain text, PDF, etc.)
-
-        render() can take arbitrary keyword parameters which will be
-        filled in from the request (in that case they *must* be
-        present in the request)."""
-
-    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(IGrokView):
-    """Grok form API, inspired by zope.formlib's IFormBaseCustomization.
-
-    We explicitly don't inherit from IFormBaseCustomization because
-    that would imply ISubPage with another definition of update() and
-    render() than IGrokView has.
-    """
-
-    prefix = schema.ASCII(
-        constraint=reConstraint(
-            '[a-zA-Z][a-zA-Z0-9_]*([.][a-zA-Z][a-zA-Z0-9_]*)*',
-            "Must be a sequence of not-separated identifiers"),
-        description=u"""Page-element prefix
-
-        All named or identified page elements in a subpage should have
-        names and identifiers that begin with a subpage prefix
-        followed by a dot.
-        """,
-        readonly=True,
-        )
-
-    def setPrefix(prefix):
-        """Update the subpage prefix
-        """
-
-    label = interface.Attribute("A label to display at the top of a form")
-
-    status = interface.Attribute(
-        """An update status message
-
-        This is normally generated by success or failure handlers.
-        """)
-
-    errors = interface.Attribute(
-        """Sequence of errors encountered during validation
-        """)
-
-    form_result = interface.Attribute(
-        """Return from action result method
-        """)
-
-    form_reset = interface.Attribute(
-        """Boolean indicating whether the form needs to be reset
-        """)
-
-    form_fields = interface.Attribute(
-        """The form's form field definitions
-
-        This attribute is used by many of the default methods.
-        """)
-
-    widgets = interface.Attribute(
-        """The form's widgets
-
-        - set by setUpWidgets
-
-        - used by validate
-        """)
-
-    def setUpWidgets(ignore_request=False):
-        """Set up the form's widgets.
-
-        The default implementation uses the form definitions in the
-        form_fields attribute and setUpInputWidgets.
-
-        The function should set the widgets attribute.
-        """
-
-    def validate(action, data):
-        """The default form validator
-
-        If an action is submitted and the action doesn't have it's own
-        validator then this function will be called.
-        """
-
-    template = interface.Attribute(
-        """Template used to display the form
-        """)
-
-    def resetForm():
-        """Reset any cached data because underlying content may have changed
-        """
-
-    def error_views():
-        """Return views of any errors.
-
-        The errors are returned as an iterable.
-        """
-
-    def applyData(obj, **data):
-        """Save form data to an object.
-
-        This returns a dictionary with interfaces as keys and lists of
-        field names as values to indicate which fields in which
-        schemas had to be changed in order to save the data.  In case
-        the method works in update mode (e.g. on EditForms) and
-        doesn't have to update an object, the dictionary is empty.
-        """
-
-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 IRESTSkinType(IInterface):
-    """Skin type for REST requests.
-    """
-
-class ITemplateFileFactory(interface.Interface):
-    """Utility that generates templates from files in template directories.
-    """
-
-    def __call__(filename, _prefix=None):
-        """Creates an ITemplate from a file
-
-        _prefix is the directory the file is located in
-        """
-
-class ITemplate(interface.Interface):
-    """Template objects
-    """
-
-    def _initFactory(factory):
-        """Template language specific initializations on the view factory."""
-
-    def render(view):
-        """Renders the template"""
-
-class IContainer(IContext, IContainerBase):
-    """A Grok container.
-    """
-
-class IViewletManager(IViewletManagerBase):
-    """The Grok viewlet manager.
-    """

Modified: five.grok/trunk/src/five/grok/meta.py
===================================================================
--- five.grok/trunk/src/five/grok/meta.py	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/meta.py	2008-07-18 15:30:38 UTC (rev 88526)
@@ -1,66 +1,25 @@
 import martian
-from martian import util
-from martian.error import GrokError
-from zope import interface, component
-from zope.publisher.interfaces.browser import (IDefaultBrowserLayer,
-                                               IBrowserRequest,
-                                               IBrowserSkinType)
 from five import grok
 
 from Products.Five.security import protectClass
 from Globals import InitializeClass as initializeClass
 
-import templatereg
+from grokcore.view.meta import ViewGrokkerBase
 
 def default_view_name(factory, module=None, **data):
     return factory.__name__.lower()
 
-class ViewGrokker(martian.ClassGrokker):
+class ViewGrokker(ViewGrokkerBase):
     martian.component(grok.View)
-    martian.directive(grok.context)
-    martian.directive(grok.layer, default=IDefaultBrowserLayer)
-    martian.directive(grok.name, get_default=default_view_name)
-    martian.directive(grok.require, name='permission')
-
-    def grok(self, name, factory, module_info, **kw):
-        # Need to store the module info object on the view class so that it
-        # can look up the 'static' resource directory.
-        factory.module_info = module_info
-        return super(ViewGrokker, self).grok(name, factory, module_info, **kw)
-
+    
     def execute(self, factory, config, context, layer, name, permission, **kw):
         if permission is None:
             permission = 'zope.Public'
-        # find templates
-        templates = factory.module_info.getAnnotation('grok.templates', None)
-        if templates is not None:
-            config.action(
-                discriminator=None,
-                callable=self.checkTemplates,
-                args=(templates, factory.module_info, factory)
-                )
-
-        # safety belt: make sure that the programmer didn't use
-        # @grok.require on any of the view's methods.
-        methods = util.methods_from_class(factory)
-        for method in methods:
-            if grok.require.bind().get(method) is not None:
-                raise GrokError('The @grok.require decorator is used for '
-                                'method %r in view %r. It may only be used '
-                                'for XML-RPC methods.'
-                                % (method.__name__, factory), factory)
-
-        # __view_name__ is needed to support IAbsoluteURL on views
-        factory.__view_name__ = name
-        adapts = (context, layer)
-
+            
+        return super(ViewGrokker, self).execute(factory, config, context, layer, name, permission, **kw)
+            
+    def protectName(self, config, factory, permission):
         config.action(
-            discriminator=('adapter', adapts, interface.Interface, name),
-            callable=component.provideAdapter,
-            args=(factory, adapts, interface.Interface, name),
-            )
-
-        config.action(
             discriminator = ('five:protectClass', factory),
             callable = protectClass,
             args = (factory, permission)
@@ -72,94 +31,3 @@
             callable = initializeClass,
             args = (factory,)
             )
-
-        return True
-
-    def checkTemplates(self, templates, module_info, factory):
-        def has_render(factory):
-            # XXX We haven't implemented GrokForm yet
-            return (getattr(factory, 'render', None))
-                    #and
-                    #not util.check_subclass(factory, grok.components.GrokForm))
-        def has_no_render(factory):
-            return not getattr(factory, 'render', None)
-        templates.checkTemplates(module_info, factory, 'view',
-                                 has_render, has_no_render)
-        
-        
-class FilesystemPageTemplateGrokker(martian.GlobalGrokker):
-    # do this early on, but after ModulePageTemplateGrokker, as
-    # findFilesystem depends on module-level templates to be
-    # already grokked for error reporting
-    martian.priority(999)
-
-    def grok(self, name, module, module_info, config, **kw):
-        templates = module_info.getAnnotation('grok.templates', None)
-        if templates is None:
-            return False
-        config.action(
-            discriminator=None,
-            callable=templates.findFilesystem,
-            args=(module_info,)
-            )
-        return True
-
-class TemplateGrokker(martian.GlobalGrokker):
-    # this needs to happen before any other grokkers execute that use
-    # the template registry
-    martian.priority(1001)
-
-    def grok(self, name, module, module_info, config, **kw):
-        module.__grok_templates__ = templatereg.TemplateRegistry()
-        return True
-    
-import grokcore.view
-class ModulePageTemplateGrokker(martian.InstanceGrokker):
-    martian.component(grokcore.view.components.BaseTemplate)
-    # this needs to happen before any other grokkers execute that actually
-    # use the templates
-    martian.priority(1000)
-    
-    def grok(self, name, instance, module_info, config, **kw):
-        templates = module_info.getAnnotation('grok.templates', None)
-        if templates is None:
-            return False
-        config.action(
-            discriminator=None,
-            callable=templates.register,
-            args=(name, instance)
-            )
-        config.action(
-            discriminator=None,
-            callable=instance._annotateGrokInfo,
-            args=(name, module_info.dotted_name)
-            )
-        return True
-    
-class UnassociatedTemplatesGrokker(martian.GlobalGrokker):
-    martian.priority(-1001)
-
-    def grok(self, name, module, module_info, config, **kw):
-        templates = module_info.getAnnotation('grok.templates', None)
-        if templates is None:
-            return False
-
-        config.action(
-            discriminator=None,
-            callable=templates.checkUnassociated,
-            args=(module_info,)
-            )
-        return True
-
-class SkinGrokker(martian.ClassGrokker):
-    martian.component(grok.Skin)
-    martian.directive(grok.layer, default=IBrowserRequest)
-    martian.directive(grok.name, get_default=default_view_name)
-
-    def execute(self, factory, config, name, layer, **kw):
-        config.action(
-            discriminator=('skin', name),
-            callable=component.interface.provideInterface,
-            args=(name, layer, IBrowserSkinType)
-            )
-        return True

Deleted: five.grok/trunk/src/five/grok/templatereg.py
===================================================================
--- five.grok/trunk/src/five/grok/templatereg.py	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/templatereg.py	2008-07-18 15:30:38 UTC (rev 88526)
@@ -1,132 +0,0 @@
-from martian.error import GrokError
-from martian import util
-
-import os
-import zope.component
-from five import grok
-import warnings
-
-class TemplateRegistry(object):
-
-    def __init__(self):
-        self._reg = {}
-
-    def register(self, name, template):
-        self._reg[name] = dict(template=template, associated=False)
-
-    def markAssociated(self, name):
-        self._reg[name]['associated'] = True
-
-    def get(self, name):
-        entry = self._reg.get(name)
-        if entry is None:
-            return None
-        return entry['template']
-
-    def findFilesystem(self, module_info):
-        template_dir_name = grok.templatedir.bind().get(
-            module=module_info.getModule())
-        if template_dir_name is None:
-            template_dir_name = module_info.name + '_templates'
-
-        template_dir = module_info.getResourcePath(template_dir_name)
-
-        if not os.path.isdir(template_dir):
-            return
-
-        if module_info.isPackage():
-            return
-
-        for template_file in os.listdir(template_dir):
-            if template_file.startswith('.') or template_file.endswith('~'):
-                continue
-
-            template_name, extension = os.path.splitext(template_file)
-            extension = extension[1:] # Get rid of the leading dot.
-            template_factory = zope.component.queryUtility(
-                grok.interfaces.ITemplateFileFactory,
-                name=extension)
-
-            if template_factory is None:
-                # Warning when importing files. This should be
-                # allowed because people may be using editors that generate
-                # '.bak' files and such.
-                warnings.warn("File '%s' has an unrecognized extension in "
-                              "directory '%s'" %
-                              (template_file, template_dir), UserWarning, 2)
-                continue
-
-            inline_template = self.get(template_name)
-            if inline_template:
-                raise GrokError("Conflicting templates found for name '%s' "
-                                "in module %r, either inline and in template "
-                                "directory '%s', or two templates with the "
-                                "same name and different extensions."
-                                % (template_name, module_info.getModule(),
-                                   template_dir), inline_template)
-
-            template = template_factory(template_file, template_dir)
-            template_path = os.path.join(template_dir, template_file)
-            template._annotateGrokInfo(template_name, template_path)
-
-            self.register(template_name, template)
-
-    def listUnassociated(self):
-        for name, entry in self._reg.iteritems():
-            if not entry['associated']:
-                yield name
-
-    def checkUnassociated(self, module_info):
-        unassociated = list(self.listUnassociated())
-        if unassociated:
-            msg = (
-                "Found the following unassociated template(s) when "
-                "grokking %r: %s.  Define view classes inheriting "
-                "from grok.View to enable the template(s)." % (
-                module_info.dotted_name, ', '.join(unassociated)))
-            warnings.warn(msg, UserWarning, 1)
-
-    def checkTemplates(self, module_info, factory, component_name,
-                       has_render, has_no_render):
-        factory_name = factory.__name__.lower()
-        template_name = grok.template.bind().get(factory)
-        if template_name is None:
-            template_name = factory_name
-
-        if factory_name != template_name:
-            # grok.template is being used
-
-            if self.get(factory_name):
-                raise GrokError("Multiple possible templates for %s %r. It "
-                                "uses grok.template('%s'), but there is also "
-                                "a template called '%s'."
-                                % (component_name, factory, template_name,
-                                   factory_name), factory)
-        template = self.get(template_name)
-        if template is not None:
-            if has_render(factory):
-                # we do not accept render and template both for a view
-                # (unless it's a form, they happen to have render.
-                raise GrokError(
-                    "Multiple possible ways to render %s %r. "
-                    "It has both a 'render' method as well as "
-                    "an associated template." %
-                    (component_name, factory), factory)
-            self.markAssociated(template_name)
-            factory.template = template
-            template._initFactory(factory)
-        else:
-            if has_no_render(factory):
-                # we do not accept a view without any way to render it
-                raise GrokError("%s %r has no associated template or "
-                                "'render' method." %
-                                (component_name.title(), factory), factory)
-
-import grokcore.view
-class PageTemplateFileFactory(grok.GlobalUtility):
-
-    grok.implements(grok.interfaces.ITemplateFileFactory)
-    grok.name('pt')
-
-    def __call__(self, filename, _prefix=None):
-        return grokcore.view.components.PageTemplate(filename=filename, _prefix=_prefix)

Modified: five.grok/trunk/src/five/grok/testing.py
===================================================================
--- five.grok/trunk/src/five/grok/testing.py	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/testing.py	2008-07-18 15:30:38 UTC (rev 88526)
@@ -23,7 +23,6 @@
     config = ConfigurationMachine()
     zcml.do_grok('grokcore.component.meta', config)
     zcml.do_grok('five.grok.meta', config)
-    zcml.do_grok('five.grok.templatereg', config)
     zcml.do_grok(module_name, config)
     config.execute_actions()
 

Deleted: five.grok/trunk/src/five/grok/util.py
===================================================================
--- five.grok/trunk/src/five/grok/util.py	2008-07-18 15:25:30 UTC (rev 88525)
+++ five.grok/trunk/src/five/grok/util.py	2008-07-18 15:30:38 UTC (rev 88526)
@@ -1,8 +0,0 @@
-from martian.error import GrokError
-from five import grok
-
-def get_name_classname(factory):
-    name = grok.name.get(factory)
-    if not name:
-        name = factory.__name__.lower()
-    return name



More information about the Checkins mailing list