[Checkins] SVN: grok/trunk/src/grok/ Interfaces documenting the Grok API.

Philipp von Weitershausen philikon at philikon.de
Wed Oct 18 06:06:02 EDT 2006


Log message for revision 70773:
  Interfaces documenting the Grok API.
  

Changed:
  U   grok/trunk/src/grok/__init__.py
  A   grok/trunk/src/grok/interfaces.py

-=-
Modified: grok/trunk/src/grok/__init__.py
===================================================================
--- grok/trunk/src/grok/__init__.py	2006-10-18 07:41:17 UTC (rev 70772)
+++ grok/trunk/src/grok/__init__.py	2006-10-18 10:05:58 UTC (rev 70773)
@@ -16,6 +16,7 @@
 
 from zope.interface import implements
 from zope.component import adapts
+from zope.event import notify
 from zope.lifecycleevent import (
     IObjectCreatedEvent, ObjectCreatedEvent,
     IObjectModifiedEvent, ObjectModifiedEvent,
@@ -26,9 +27,12 @@
     IObjectRemovedEvent, ObjectRemovedEvent,
     IContainerModifiedEvent, ContainerModifiedEvent)
 
-from zope.event import notify
-
 from grok._grok import (Model, Adapter, MultiAdapter, View, PageTemplate,
-                   grok, context, name, template, templatedir, )
+                        grok, context, name, template, templatedir, )
 from grok._grok import SubscribeDecorator as subscribe
 from grok.error import GrokError, GrokImportError
+
+from grok.interfaces import IGrokAPI
+from zope.interface import moduleProvides
+moduleProvides(IGrokAPI)
+__all__ = list(IGrokAPI)

Added: grok/trunk/src/grok/interfaces.py
===================================================================
--- grok/trunk/src/grok/interfaces.py	2006-10-18 07:41:17 UTC (rev 70772)
+++ grok/trunk/src/grok/interfaces.py	2006-10-18 10:05:58 UTC (rev 70773)
@@ -0,0 +1,116 @@
+##############################################################################
+#
+# Copyright (c) 2006 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
+
+class IGrokBaseClasses(interface.Interface):
+
+    Model = interface.Attribute("Base class for persistent content objects "
+                                "(models).")
+    Adapter = interface.Attribute("Base class for adapters.")
+    MultiAdapter = interface.Attribute("Base class for multi-adapters.")
+    View = interface.Attribute("Base class for browser views.")
+
+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 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``."""
+
+class IGrokDecorators(interface.Interface):
+
+    def subscribe(*classes_or_interfaces):
+        """Declare that a function subscribes to an event or a
+        combination of objects and events."""
+
+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 notify(event):
+        """Send ``event`` to event subscribers."""
+
+    def PageTemplate(template):
+        """Create a Grok PageTemplate object from ``template`` source
+        text.  This can be used for inline PageTemplates."""


Property changes on: grok/trunk/src/grok/interfaces.py
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Checkins mailing list