[Checkins] SVN: grokcore.view/trunk/src/grokcore/view/ Introduce interface to describe this package's API as well

Philipp von Weitershausen philikon at philikon.de
Mon Jul 28 18:28:55 EDT 2008


Log message for revision 88929:
  Introduce interface to describe this package's API as well
  

Changed:
  U   grokcore.view/trunk/src/grokcore/view/__init__.py
  U   grokcore.view/trunk/src/grokcore/view/interfaces.py

-=-
Modified: grokcore.view/trunk/src/grokcore/view/__init__.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/__init__.py	2008-07-28 22:18:49 UTC (rev 88928)
+++ grokcore.view/trunk/src/grokcore/view/__init__.py	2008-07-28 22:28:55 UTC (rev 88929)
@@ -10,3 +10,7 @@
 # Import this module so that it's available as soon as you import the
 # 'grokcore.view' package.  Useful for tests and interpreter examples.
 import grokcore.view.testing
+
+# Only export public API
+from grokcore.view.interfaces import IGrokcoreViewAPI
+__all__ = list(IGrokcoreViewAPI)

Modified: grokcore.view/trunk/src/grokcore/view/interfaces.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/interfaces.py	2008-07-28 22:18:49 UTC (rev 88928)
+++ grokcore.view/trunk/src/grokcore/view/interfaces.py	2008-07-28 22:28:55 UTC (rev 88929)
@@ -1,20 +1,19 @@
-from zope import interface
+from zope.interface import Interface, Attribute
 from zope.publisher.interfaces.browser import IBrowserPage, IBrowserView
 
 
 class IGrokView(IBrowserPage, IBrowserView):
     """Grok views all provide this interface."""
 
-    context = interface.Attribute('context', "Object that the view presents.")
+    context = Attribute('context', "Object that the view presents.")
 
-    request = interface.Attribute('request', "Request that the view was looked"
-                                  "up with.")
+    request = Attribute('request', "Request that the view was looked up with.")
 
-    response = interface.Attribute('response', "Response object that is "
-                                   "associated with the current request.")
+    response = 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.")
+    static = Attribute('static', "Directory resource containing the static "
+                       "files of the view's package.")
 
     def redirect(url):
         """Redirect to given URL"""
@@ -79,7 +78,7 @@
         """
 
 
-class ITemplateFileFactory(interface.Interface):
+class ITemplateFileFactory(Interface):
     """Utility that generates templates from files in template directories.
     """
 
@@ -90,7 +89,7 @@
         """
 
 
-class ITemplate(interface.Interface):
+class ITemplate(Interface):
     """Template objects
     """
 
@@ -99,3 +98,62 @@
 
     def render(view):
         """Renders the template"""
+
+
+class IBaseClasses(Interface):
+    View = Attribute("Base class for browser views.")
+    Skin = Attribute("Base class for skin.")
+    IGrokLayer = Attribute("Base interface for layers (deprecated)")
+
+class IDirectives(Interface):
+
+    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 view(class_or_interface):
+        """Declare which view or kind of view the component should be
+        registered for.
+
+        This directive is useful on viewlets, for instance, and can be
+        used on a class or module level."""
+
+class IAPI(Interface):
+
+    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 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``."""
+
+class IGrokcoreViewAPI(IBaseClasses, IDirectives, IAPI):
+    """grokcore.view's public API."""
+



More information about the Checkins mailing list