[Checkins] SVN: Sandbox/darrylcousins/mars.formdemo/ Brought in original z3c README, wrote a little in this README and simplified views

Darryl Cousins darryl at darrylcousins.net.nz
Sat Jul 7 07:32:46 EDT 2007


Log message for revision 77567:
  Brought in original z3c README, wrote a little in this README and simplified views

Changed:
  U   Sandbox/darrylcousins/mars.formdemo/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/README.z3c.txt
  U   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py
  U   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py
  U   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py

-=-
Modified: Sandbox/darrylcousins/mars.formdemo/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/README.txt	2007-07-07 11:32:18 UTC (rev 77566)
+++ Sandbox/darrylcousins/mars.formdemo/README.txt	2007-07-07 11:32:46 UTC (rev 77567)
@@ -5,38 +5,26 @@
 This package is a ``mars`` implementation which seeks to duplicate the original
 z3c.formdemo demo applications.
 
-Original README from z3c.formdemo
----------------------------------
+The original README is README.z3c.txt.
 
-This package contains several small demo applications for the ``z3c.form`` and
-``z3c.formui`` packages.
+`Grok`_ is a project which seeks to ....
 
-* TABLE- versus DIV-based layout of all widgets.
+``Martian`` grew from `Grok`_:
 
-* A simple Hello World message application demonstrating the easiest way to
-  write add, edit and display forms.
+ Martian provides a framework that allows configuration to be expressed
+ in declarative Python code. These declarations can often be deduced
+ from the structure of the code itself. The idea is to make these
+ declarations so minimal and easy to read that even extensive
+ configuration does not overly burden the programmers working with the
+ code. Configuration actions are executed during a separate phase
+ ("grok time"), not at import time, which makes it easier to reason
+ about and easier to test.
 
-* A simple calculator showing the flexibility of the new action declaration
-  framework by declaring different classes of buttons.
+ The ``martian`` package is a spin-off from the `Grok`_ project, in the
+ context of which this codebase was first developed. While Grok uses
+ it, the code is completely independent of Grok.
 
-* A linear wizard shows off the sub-form capabilities of z3c.form. It also
-  demonstrates how one can overcome the short-coming of an object widget.
-
-* A simple table/spreadsheet that allows adding and editing as simple content
-  object. This demo also shows the usage of forms and ``zc.table`` at the same
-  time.
-
-Running the Demo out of the box
--------------------------------
-
-You can also run the demo directly without manually installing Zope 3::
-
-  $ svn co svn://svn.zope.org/repos/main/Sandbox/darrylcousins/mars.formdemo
-  $ cd mars.formdemo
-  $ python bootstrap.py
-  $ ./bin/buildout
-  $ ./bin/demo fg
-
-Then access the demo site using:
-
-  http://localhost:8080/
+The ``mars`` packages which are included here as develop eggs grew from
+answering the duties of the zcml directives used to configure the original
+``z3c.formdemo`` demos. These packages use both `Grok`_ and ``Martian``.
+``Martian`` to register the ``Grokkers`` and `Grok`_ does the grokking.

Added: Sandbox/darrylcousins/mars.formdemo/README.z3c.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/README.z3c.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/README.z3c.txt	2007-07-07 11:32:46 UTC (rev 77567)
@@ -0,0 +1,43 @@
+=====================================================
+Demo Applications for ``z3c.form`` and ``z3c.formui``
+=====================================================
+
+This package is a ``mars`` implementation which seeks to duplicate the original
+z3c.formdemo demo applications.
+
+Original README from z3c.formdemo
+---------------------------------
+
+This package contains several small demo applications for the ``z3c.form`` and
+``z3c.formui`` packages.
+
+* TABLE- versus DIV-based layout of all widgets.
+
+* A simple Hello World message application demonstrating the easiest way to
+  write add, edit and display forms.
+
+* A simple calculator showing the flexibility of the new action declaration
+  framework by declaring different classes of buttons.
+
+* A linear wizard shows off the sub-form capabilities of z3c.form. It also
+  demonstrates how one can overcome the short-coming of an object widget.
+
+* A simple table/spreadsheet that allows adding and editing as simple content
+  object. This demo also shows the usage of forms and ``zc.table`` at the same
+  time.
+
+Running the Demo out of the box
+-------------------------------
+
+You can also run the demo directly without manually installing Zope 3::
+
+  $ svn co svn://svn.zope.org/repos/main/Sandbox/darrylcousins/mars.formdemo
+  $ cd mars.formdemo
+  $ python bootstrap.py
+  $ ./bin/buildout
+  $ ./bin/demo fg
+
+Then access the demo site using:
+
+  http://localhost:8080/
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/README.z3c.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Modified: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py	2007-07-07 11:32:18 UTC (rev 77566)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py	2007-07-07 11:32:46 UTC (rev 77567)
@@ -1,6 +1,6 @@
-from mars.view.components import TemplateViewBase, ViewBase
+from mars.view.components import TemplateViewBase
 
-class ContentProvider(ViewBase, TemplateViewBase):
+class ContentProvider(TemplateViewBase):
 
     def __init__(self, context, request, view):
         self.__parent__ = self.view = view

Modified: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py	2007-07-07 11:32:18 UTC (rev 77566)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py	2007-07-07 11:32:46 UTC (rev 77567)
@@ -11,71 +11,6 @@
 import grok
 from grok.interfaces import IGrokView
 
-class ViewBase(object):
-    """Maybe this could be in the grok.components module?
-    
-    All of this is directly copied from grok.View"""
-
-    template_name = u''
-    _updated = False
-
-    def application(self):
-        obj = self.context
-        while obj is not None:
-            if isinstance(obj, grok.Application):
-                return obj
-            obj = obj.__parent__
-        raise ValueErrror("No application found.")
-
-    def site(self):
-        obj = self.context
-        while obj is not None:
-            if isinstance(obj, grok.Site):
-                return obj
-            obj = obj.__parent__
-        raise ValueErrror("No site found.")
-
-    def application_url(self, name=None):
-        obj = self.context
-        while obj is not None:
-            if isinstance(obj, grok.Application):
-                return self.url(obj, name)
-            obj = obj.__parent__
-        raise ValueErrror("No application found.")
-
-    def url(self, obj=None, name=None):
-        # if the first argument is a string, that's the name. There should
-        # be no second argument
-        if isinstance(obj, basestring):
-            if name is not None:
-                raise TypeError(
-                    'url() takes either obj argument, obj, string arguments, '
-                    'or string argument')
-            name = obj
-            obj = None
-
-        if name is None and obj is None:
-            # create URL to view itself
-            obj = self
-        elif name is not None and obj is None:
-            # create URL to view on context
-            obj = self.context
-        return url(self.request, obj, name)
-        
-    def redirect(self, url):
-        return self.request.response.redirect(url)
-        
-    @property
-    def response(self):
-        return self.request.response
-
-    def update(self):
-        pass
-
-    #def __getitem__(self, key):
-    #    # give nice error message if template is None
-    #    return self.template.macros[key]
-
 class TemplateViewBase(object):
     """Mixin to reuse render method"""
     template = None
@@ -83,8 +18,6 @@
     _template_interface = IPageTemplate
 
     def render(self):
-        mapply(self.update, (), self.request)
-        self._updated = True # prevent update being called again
         if self.request.response.getStatus() in (302, 303):
             return
         template = getattr(self, 'template', None)
@@ -95,9 +28,12 @@
             return template(self)
         return template(self)
 
+    def update(self):
+        pass
 
-class TemplateView(ViewBase, TemplateViewBase, BrowserPage):
 
+class TemplateView(TemplateViewBase, BrowserPage):
+
     def __init__(self, context, request):
         super(TemplateView, self).__init__(context, request)
 
@@ -107,9 +43,11 @@
     _layout_name = u'' # will be set if mars.view.layout defined
     _layout_interface = ILayoutTemplate
 
+    def update(self):
+        pass
+
     def __call__(self):
-        if not self._updated: # may already be called in render method
-            mapply(self.update, (), self.request)
+        self.update()
         if self.request.response.getStatus() in (302, 303):
             return
         layout = getattr(self, 'layout', None)
@@ -120,12 +58,12 @@
             return layout(self)
         return layout(self)
 
-class LayoutView(ViewBase, LayoutViewBase, BrowserPage):
+class LayoutView(LayoutViewBase, BrowserPage):
 
     def __init__(self, context, request):
         super(LayoutView, self).__init__(context, request)
 
-class PageletView(ViewBase, TemplateViewBase, LayoutViewBase, BrowserPage):
+class PageletView(TemplateViewBase, LayoutViewBase, BrowserPage):
     zope.interface.implements(IPagelet)
 
     def __init__(self, context, request):

Modified: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py	2007-07-07 11:32:18 UTC (rev 77566)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py	2007-07-07 11:32:46 UTC (rev 77567)
@@ -8,14 +8,14 @@
 
 from martian import util
 
-from mars.view.components import TemplateViewBase, ViewBase
+from mars.view.components import TemplateViewBase
 
 class SimpleViewlet(object):
     """Vanilla object to mixin with zope.viewlet viewlets
     No methods at all are provided, just the registration"""
     pass
 
-class Viewlet(TemplateViewBase, ViewBase, BrowserView):
+class Viewlet(TemplateViewBase, BrowserView):
     zope.interface.implements(IViewlet)
 
     def __init__(self, context, request, view, manager):
@@ -24,7 +24,7 @@
         self.request = request
         self.manager = manager
 
-class ViewletManager(WeightOrderedViewletManager, ViewBase, TemplateViewBase):
+class ViewletManager(WeightOrderedViewletManager, TemplateViewBase):
     zope.interface.implements(IViewletManager)
 
     def __init__(self, context, request, view):
@@ -47,10 +47,7 @@
             except ComponentLookupError:
                 return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
 
-    def update_manager(self):
-        WeightOrderedViewletManager.update(self)
 
-
     def filter(self, viewlets):
         """Sort out all content providers
 



More information about the Checkins mailing list