[Checkins] SVN: Sandbox/darrylcousins/mars.formdemo/ Initial import of mars.formdemo

Darryl Cousins darryl at darrylcousins.net.nz
Fri Jul 6 17:09:42 EDT 2007


Log message for revision 77533:
  Initial import of mars.formdemo

Changed:
  A   Sandbox/darrylcousins/mars.formdemo/
  A   Sandbox/darrylcousins/mars.formdemo/AUTHOR.txt
  A   Sandbox/darrylcousins/mars.formdemo/CHANGES.txt
  A   Sandbox/darrylcousins/mars.formdemo/LICENSE.txt
  A   Sandbox/darrylcousins/mars.formdemo/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/bootstrap.py
  A   Sandbox/darrylcousins/mars.formdemo/buildout.cfg
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/adapter/
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/components.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/interfaces.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/adapter.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/test_all.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/interfaces.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/contentprovider.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/index.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/test_all.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/components.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/interfaces.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal-ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet-ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/test_all.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/components.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/interfaces.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/macro.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/first.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/navigation.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/test_all.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/components.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/interfaces.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resource.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resources/
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resources/logo.jpg
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resources/site.css
  A   Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/test_all.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/components.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/interfaces.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/layout.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/minimal-ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/template.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/complex.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/macro.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/plain.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/view.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/test_all.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/interfaces.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/layout.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/pagelet.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/template.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/layout.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/template.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/test_all.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.txt
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/interfaces.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/index.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/test_all.py
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.pt
  A   Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.py
  A   Sandbox/darrylcousins/mars.formdemo/setup.py
  A   Sandbox/darrylcousins/mars.formdemo/setup.z3c.py
  A   Sandbox/darrylcousins/mars.formdemo/src/
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/application.zcml
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/browser.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/index.pt
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/configure.zcml
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/ftesting.zcml
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/layer.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/README.txt
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/display.pt
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/message.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/what-values.csv
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/__init__.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/demo.css
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/images/
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/images/loading.gif
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/images/loading.png
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/skin.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/template.pt
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/testing.py
  A   Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/tests.py

-=-
Added: Sandbox/darrylcousins/mars.formdemo/AUTHOR.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/AUTHOR.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/AUTHOR.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,5 @@
+Darryl Cousins (darrl.cousins <at> tfws.org.nz)
+
+Authors of the original z3c.formdemo package:
+Stephan Richter (stephan.richter <at> gmail.com)
+Roger Ineichen (roger <at> projekt01.ch)


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

Added: Sandbox/darrylcousins/mars.formdemo/CHANGES.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/CHANGES.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/CHANGES.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,8 @@
+=======
+CHANGES
+=======
+
+Version 1.0.0 (7/8/2007)
+-------------------------
+
+- Initial Release


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

Added: Sandbox/darrylcousins/mars.formdemo/LICENSE.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/LICENSE.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/LICENSE.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,54 @@
+Zope Public License (ZPL) Version 2.1
+-------------------------------------
+
+A copyright notice accompanies this license document that
+identifies the copyright holders.
+
+This license has been certified as open source. It has also
+been designated as GPL compatible by the Free Software
+Foundation (FSF).
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the
+following conditions are met:
+
+1. Redistributions in source code must retain the
+   accompanying copyright notice, this list of conditions,
+   and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the accompanying
+   copyright notice, this list of conditions, and the
+   following disclaimer in the documentation and/or other
+   materials provided with the distribution.
+
+3. Names of the copyright holders must not be used to
+   endorse or promote products derived from this software
+   without prior written permission from the copyright
+   holders.
+
+4. The right to distribute this software or to use it for
+   any purpose does not give you the right to use
+   Servicemarks (sm) or Trademarks (tm) of the copyright
+   holders. Use of them is covered by separate agreement
+   with the copyright holders.
+
+5. If any files are modified, you must cause the modified
+   files to carry prominent notices stating that you changed
+   the files and the date of any change.
+
+Disclaimer
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS''
+  AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+  NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+  NO EVENT SHALL THE COPYRIGHT HOLDERS BE
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+  DAMAGE.


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

Added: Sandbox/darrylcousins/mars.formdemo/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,42 @@
+=====================================================
+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.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/bootstrap.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/bootstrap.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/bootstrap.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                     ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+    cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+    os.P_WAIT, sys.executable, sys.executable,
+    '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+    dict(os.environ,
+         PYTHONPATH=
+         ws.find(pkg_resources.Requirement.parse('setuptools')).location
+         ),
+    ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)


Property changes on: Sandbox/darrylcousins/mars.formdemo/bootstrap.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/buildout.cfg
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/buildout.cfg	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/buildout.cfg	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,39 @@
+[buildout]
+develop = . mars.layer mars.template mars.macro mars.view mars.contentprovider mars.viewlet mars.resource mars.adapter
+parts = demo test
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = mars.formdemo [app, test]
+       mars.layer
+       mars.template
+       mars.macro
+       mars.view
+       mars.viewlet
+       mars.contentprovider
+       mars.resource
+       mars.adapter
+
+[zope3]
+location = .
+
+[form-demo-app]
+recipe = zc.zope3recipes:app
+site.zcml = <include package="mars.formdemo" file="application.zcml" />
+eggs = mars.formdemo [app]
+       mars.layer
+       mars.template
+       mars.macro
+       mars.view
+       mars.viewlet
+       mars.contentprovider
+       mars.resource
+       mars.adapter
+
+[demo]
+recipe = zc.zope3recipes:instance
+application = form-demo-app
+zope.conf = ${database:zconfig}
+
+[database]
+recipe = zc.recipe.filestorage

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,33 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.adapter',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/martian',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to define z3c.adapter macros""",
+    long_description=(
+        read('src/mars/adapter/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    install_requires=['setuptools',
+                      'martian',
+                      'grok',
+                     ],
+)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,31 @@
+============
+Mars Adapter
+============
+
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+z3c packages bring significant clarity and a pattern for forms, view and
+templates.
+
+This package uses martian to register adapter factories.
+
+Example Code
+------------
+
+::
+
+    Code
+
+Directives
+----------
+
+Please see ``directive.txt``.
+
+Tests
+-----
+
+See test directory.
+
+


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

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+from directive import factory
+from components import AdapterFactory
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/components.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/components.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+
+class AdapterFactory(object):
+    pass


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/components.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,18 @@
+from martian.directive import (OnceDirective,
+                               SingleValue,
+                               ClassDirectiveContext)
+
+class MethodDirective(SingleValue, OnceDirective):
+    """
+    Directive that only accepts factories??
+    """
+
+# FIXME
+    def check_arguments(self, value):
+        return True
+        #if not (IInterface.providedBy(value) or util.isclass(value)):
+        #    raise GrokImportError("You can only pass classes or interfaces to "
+        #                          "%s." % self.name)
+
+factory = MethodDirective('mars.adapter.factory',
+                                 ClassDirectiveContext())


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,18 @@
+=======================
+Mars Adapter Directives
+=======================
+
+Directives specific to this package
+-----------------------------------
+
+* mars.adapter.factory(factory):
+  The factory to be registered
+  **Required**
+
+Relevant grok directives
+------------------------
+
+* grok.name(name):
+  If defined the factory will be registered as a `named adapter`.
+  Default: empty string
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/directive.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/interfaces.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/interfaces.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/interfaces.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,8 @@
+import zope.interface
+
+class IMarsAdapterDirectives(zope.interface.Interface):
+
+    def factory(factory):
+        """The factory to be registered as an adapter"""
+        pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,28 @@
+import zope.component
+
+import grok
+
+import martian
+from martian import util
+
+import mars.adapter
+
+class AdapterFactoryGrokker(martian.ClassGrokker):
+    component_class = mars.adapter.AdapterFactory
+
+    def grok(self, name, factory, context, module_info, templates):
+        adapter_context = util.determine_class_context(factory, context)
+        provides = util.class_annotation(factory, 'grok.provides', None)
+        name = util.class_annotation(factory, 'grok.name', '')
+        factory = util.class_annotation(factory, 'mars.adapter.factory', None)
+        if factory is None:
+            # TODO error message
+            pass
+        else:
+            #zope.component.provideAdapter(factory, adapts=(adapter_context,),
+            #                         provides=provides,
+            #                         name=name)
+            zope.component.provideAdapter(factory,
+                                     name=name)
+        return True
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/meta.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/adapter.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/adapter.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/adapter.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,17 @@
+"""
+Test the claimed directives.
+
+  >>> import grok
+  >>> grok.grok('mars.adapter.tests.adapter')
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+
+TODO
+
+"""
+
+import grok
+import mars.adapter
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/adapter.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,16 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.adapter" file="meta.zcml" />
+
+  <include package="z3c.layer.minimal.tests" file="ftesting.zcml" />
+
+  <include package="grok" />
+
+</configure>
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/test_all.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/test_all.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/test_all.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,22 @@
+import unittest
+from pkg_resources import resource_listdir
+
+from grok.ftests.test_grok_functional import FunctionalDocTestSuite
+
+from zope.app.testing import functional
+functional.defineLayer('TestLayer', 'ftesting.zcml')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    dottedname = 'mars.adapter.tests.%s'
+    for name in ['adapter']:
+        test = FunctionalDocTestSuite(dottedname % name)
+        test.layer = TestLayer
+        suite.addTest(test)
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.adapter/src/mars/adapter/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,33 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.contentprovider',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/martian',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to define contentproviders""",
+    long_description=(
+        read('src/mars/contentprovider/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    install_requires=['setuptools',
+                      'martian',
+                      'zope.contentprovider',
+                     ],
+)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,42 @@
+====================
+Mars ContentProvider
+====================
+
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to configure contentproviders.
+
+Example Code
+------------
+
+::
+
+ class Index(mars.view.LayoutView):
+     pass
+
+ class IndexLayout(mars.template.LayoutFactory):
+     grok.template('index.pt')
+     grok.context(Index)
+
+ class Title(mars.contentprovider.ContentProvider):
+
+     def render(self):
+         return self.context.title
+
+Template for index may be::
+
+ <tal:block tal:content="structure provider:title" />
+
+Directives
+----------
+
+Please see ``directive.txt``.
+
+Tests
+-----
+
+See test directory.
+
+


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

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+from components import ContentProvider
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,8 @@
+from mars.view.components import TemplateViewBase, ViewBase
+
+class ContentProvider(ViewBase, TemplateViewBase):
+
+    def __init__(self, context, request, view):
+        self.__parent__ = self.view = view
+        self.context = context
+        self.request = request


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/components.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,31 @@
+===============================
+Mars ContentProvider Directives
+===============================
+
+The mars.layer directive may be used
+-----------------------------------------
+
+* mars.layer.layer(class_or_interface):
+  The layer for which the template should be available.
+  Default: zope.publisher.browser.interfaces.IDefaultBrowserLayer
+
+Relevant grok directives
+------------------------
+
+* grok.name(name):
+  Name of the view, available in url as object/@@viewname.
+  Default: factory.__name__.lower()
+
+* grok.context(class_or_interface):
+  The view for which the template should be available. Usually should be
+  defined.
+  Default: module context
+
+* grok.template(name):
+  If defined the template will be looked up as a `named adapter`. Should only be
+  defined if a template has been registered as a named adapter.
+  Default: ''
+
+* grok.provides(class_or_interface):
+  Interface the class is looked up as, probably wouldn't be used.
+  Default: zope.interface.Interface


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/directive.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/interfaces.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/interfaces.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/interfaces.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,4 @@
+import zope.interface
+
+class IMarsContentProviderDirectives(zope.interface.Interface):
+    pass


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,18 @@
+import zope.component
+from zope.publisher.interfaces.browser import IBrowserView
+from zope.contentprovider.interfaces import IContentProvider
+
+import mars.contentprovider
+from mars.view.meta import ViewGrokkerBase
+
+class ContentProviderGrokker(ViewGrokkerBase):
+    component_class = mars.contentprovider.ContentProvider
+    provides = IContentProvider
+    
+    def register(self, factory, module_info):
+
+        zope.component.provideAdapter(factory,
+                                 adapts=(self.view_context, self.view_layer, IBrowserView),
+                                 provides=self.provides,
+                                 name=self.view_name)
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/meta.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/contentprovider.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/contentprovider.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/contentprovider.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,48 @@
+"""
+  >>> import grok
+  >>> grok.grok('mars.contentprovider.tests.contentprovider')
+  >>> from mars.contentprovider.tests.contentprovider import Mammoth
+  >>> getRootFolder()["mammoth"] = Mammoth()
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+  >>> skinURL = 'http://localhost/++skin++myskin'
+  >>> browser.open(skinURL + '/mammoth/@@index')
+  >>> print browser.contents
+  <div>
+  I am Manfred the Mammoth
+  </div>
+
+"""
+
+import grok
+import mars.view
+import mars.layer
+import mars.template
+import mars.contentprovider
+
+class IMySkinLayer(mars.layer.IMinimalLayer):
+    pass
+
+# layer used for all registrations in this module
+mars.layer.layer(IMySkinLayer)
+
+class MySkin(mars.layer.Skin):
+    pass
+
+class Mammoth(grok.Model):
+    title = u'Manfred'
+
+class Index(mars.view.LayoutView):
+    pass
+
+class IndexLayout(mars.template.LayoutFactory):
+    grok.template('index.pt')
+    grok.context(Index)
+
+class Title(mars.contentprovider.ContentProvider):
+
+    def render(self):
+        return self.context.title
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/contentprovider.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,20 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.contentprovider.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+  <include package="mars.view" file="meta.zcml" />
+  <include package="mars.contentprovider" file="meta.zcml" />
+
+  <include package="z3c.layer.minimal.tests" file="ftesting.zcml" />
+
+  <include package="grok" />
+  <include package="zope.contentprovider" />
+
+</configure>
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/index.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/index.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/index.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+<div>
+I am <tal:block tal:content="structure provider:title" /> the Mammoth
+</div>

Added: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/test_all.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/test_all.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/test_all.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,22 @@
+import unittest
+from pkg_resources import resource_listdir
+
+from grok.ftests.test_grok_functional import FunctionalDocTestSuite
+
+from zope.app.testing import functional
+functional.defineLayer('TestLayer', 'ftesting.zcml')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    dottedname = 'mars.contentprovider.tests.%s'
+    for name in ['contentprovider']:
+        test = FunctionalDocTestSuite(dottedname % name)
+        test.layer = TestLayer
+        suite.addTest(test)
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.contentprovider/src/mars/contentprovider/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,35 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.layer',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/martian',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to define layers and skins""",
+    long_description=(
+        read('src/mars/layer/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    install_requires=['setuptools',
+                      'martian',
+                      'z3c.layer',
+                      'z3c.pagelet',
+                      'z3c.form',
+                     ],
+)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,42 @@
+==========
+Mars Layer
+==========
+
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to define layers and skins.
+
+The base layers available are:
+
+* mars.layer.IMinimalLayer
+  Uses z3c.layer.IMinimalBrowserLayer
+
+* mars.layer.IPageletLayer
+  Uses z3c.layer.IPageletBrowserLayer
+
+Example Code
+------------
+
+::
+
+  import mars.layer
+
+  class IMyLayer(mars.layer.IMinimalLayer):
+      pass
+
+  class MySkin(mars.layer.Skin):
+      mars.layer.layer(IMyLayer)
+
+Skin is available as http://localhost/++skin++myskin
+
+Directives
+----------
+
+Please see ``directive.txt``.
+
+Tests
+-----
+
+See test directory.


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

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,9 @@
+from directive import layer
+from components import (Skin, 
+                        ILayer,
+                        IMinimalLayer, 
+                        IPageletLayer,
+                        IFormLayer,
+                        IDivFormLayer,
+                        ITableFormLayer)
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/components.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/components.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,30 @@
+from zope.publisher.interfaces.browser import IBrowserRequest
+import zope.interface
+from z3c.layer.pagelet import IPageletBrowserLayer
+from z3c.layer.minimal import IMinimalBrowserLayer
+from z3c.form.interfaces import IFormLayer as IZ3CFormLayer
+from z3c.formui.interfaces import IDivFormLayer as IZ3CDivFormLayer
+from z3c.formui.interfaces import ITableFormLayer as IZ3CTableFormLayer
+
+class ILayer(zope.interface.Interface):
+    pass
+
+class IMinimalLayer(ILayer, IMinimalBrowserLayer):
+    pass
+
+class IPageletLayer(ILayer, IPageletBrowserLayer):
+    pass
+
+class IFormLayer(ILayer, IZ3CFormLayer, IPageletBrowserLayer):
+    pass
+
+class IDivFormLayer(ILayer, IZ3CDivFormLayer, IZ3CFormLayer, IPageletBrowserLayer):
+    pass
+
+class ITableFormLayer(ILayer, IZ3CTableFormLayer, IZ3CFormLayer, IPageletBrowserLayer):
+    pass
+
+class Skin(object):
+    pass
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/components.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,5 @@
+from martian.directive import (InterfaceOrClassDirective,
+                            ClassOrModuleDirectiveContext)
+
+layer = InterfaceOrClassDirective('mars.layer.layer',
+                           ClassOrModuleDirectiveContext())


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,18 @@
+=====================
+Mars Layer Directives
+=====================
+
+Directives specific to this package
+-----------------------------------
+
+* mars.layer.layer(class_or_interface):
+  The layer for which the object should be available.
+  Default: zope.publisher.browser.interfaces.IBrowserRequest
+
+Relevant grok directives
+------------------------
+
+* grok.name(name):
+  The name for which the skin is registered.
+  Default: factory.__name__.lower()
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/directive.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/interfaces.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/interfaces.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/interfaces.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,8 @@
+import zope.interface
+
+class IMarsLayerDirectives(zope.interface.Interface):
+
+    def layer(class_or_interface):
+        """The layer for which the object should be available.
+        Default: zope.publisher.browser.interfaces.IBrowserRequest
+        """


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,25 @@
+import martian
+import grok
+import zope.component
+from zope.publisher.interfaces.browser import (IDefaultBrowserLayer,
+                                               IBrowserRequest,
+                                               IBrowserSkinType)
+from martian import util
+import mars.layer
+from mars.layer.components import ILayer
+
+class ILayerGrokker(martian.ClassGrokker):
+    component_class = ILayer
+
+class SkinGrokker(martian.ClassGrokker):
+    component_class = mars.layer.Skin
+
+    def grok(self, name, factory, context, module_info, templates):
+        layer = util.class_annotation(factory, 'mars.layer.layer',
+                                    None) or module_info.getAnnotation('mars.layer.layer',
+                                    None) or IBrowserRequest
+        name = grok.util.class_annotation(factory, 'grok.name', factory.__name__.lower())
+        #print '\nName: ', name, 'Factory: ', factory, 'layer: ', layer, '\n'
+        zope.component.interface.provideInterface(name, layer, IBrowserSkinType)
+
+        return True


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/meta.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,42 @@
+"""
+Test the claimed directives.
+
+  >>> import grok
+  >>> grok.grok('mars.layer.tests.directive')
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+
+  >>> skinURL = 'http://localhost/++skin++namedskin'
+
+Try opening page.htm which is registered in ftesting.zcml for
+z3c.layer.IMinimalBrowserLayer.
+
+  >>> browser.open(skinURL + '/page.html')
+  >>> print browser.contents
+  <BLANKLINE>
+  <html>
+  <head>
+    <title>testing</title>
+  </head>
+  <body>
+  <BLANKLINE>
+    test page
+  <BLANKLINE>
+  </body>
+  </html>
+  <BLANKLINE>
+  <BLANKLINE>
+
+"""
+import grok
+import mars.layer
+
+class IMyLayer(mars.layer.IMinimalLayer):
+    pass
+
+class MySkin(mars.layer.Skin):
+    grok.name('namedskin')
+    mars.layer.layer(IMyLayer)
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal-ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal-ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal-ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,19 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+
+  <include package="z3c.layer.minimal.tests" file="ftesting.zcml" />
+
+  <include package="grok" />
+
+</configure>
+
+
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,46 @@
+"""
+
+  >>> import grok
+  >>> grok.grok('mars.layer.tests.minimal')
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+
+  >>> skinURL = 'http://localhost/++skin++myskin'
+
+Try opening page.htm which is registered in ftesting.zcml for
+z3c.layer.IMinimalBrowserLayer.
+
+  >>> browser.open(skinURL + '/page.html')
+  >>> print browser.contents
+  <BLANKLINE>
+  <html>
+  <head>
+    <title>testing</title>
+  </head>
+  <body>
+  <BLANKLINE>
+    test page
+  <BLANKLINE>
+  </body>
+  </html>
+  <BLANKLINE>
+  <BLANKLINE>
+
+
+"""
+
+import grok
+import mars.layer
+
+class IMyLayer(mars.layer.IMinimalLayer):
+    pass
+
+# layer can be set on module level and will therefore be the layer
+# for all views, template and macros in the module
+mars.layer.layer(IMyLayer)
+
+class MySkin(mars.layer.Skin):
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/minimal.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet-ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet-ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet-ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,20 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+
+  <include package="z3c.layer.pagelet.tests" file="ftesting.zcml" />
+
+  <include package="grok" />
+
+</configure>
+
+
+
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,41 @@
+"""
+
+  >>> import grok
+  >>> grok.grok('mars.layer.tests.pagelet')
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+
+  >>> skinURL = 'http://localhost/++skin++myskin'
+
+Try opening page.htm which is registered in ftesting.zcml for
+z3c.layer.IPageletBrowserLayer.
+
+  >>> browser.open(skinURL + '/page.html')
+  >>> print browser.contents
+  <!DOCTYPE...
+  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+  <title>TestingSkin</title>
+  </head>
+  <body>
+    test page
+  <BLANKLINE>
+  </body>
+  </html>
+  <BLANKLINE>
+
+
+"""
+
+import grok
+import mars.layer
+
+class IMyLayer(mars.layer.IPageletLayer):
+    pass
+
+class MySkin(mars.layer.Skin):
+    mars.layer.layer(IMyLayer)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/pagelet.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/test_all.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/test_all.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/test_all.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,29 @@
+import unittest
+from pkg_resources import resource_listdir
+
+from grok.ftests.test_grok_functional import FunctionalDocTestSuite
+
+from zope.app.testing import functional
+functional.defineLayer('TestMinimalLayer', 'minimal-ftesting.zcml')
+functional.defineLayer('TestPageletLayer', 'pagelet-ftesting.zcml')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    dottedname = 'mars.layer.tests.%s'
+    for name in ['minimal', 'directive']:
+        test = FunctionalDocTestSuite(dottedname % name)
+        test.layer = TestMinimalLayer
+        suite.addTest(test)
+
+    test = FunctionalDocTestSuite(dottedname % 'pagelet')
+    test.layer = TestPageletLayer
+    suite.addTest(test)
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.layer/src/mars/layer/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,33 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.macro',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/martian',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to define z3c.macro macros""",
+    long_description=(
+        read('src/mars/macro/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    install_requires=['setuptools',
+                      'martian',
+                      'z3c.macro',
+                     ],
+)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,39 @@
+==========
+Mars Macro
+==========
+
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+z3c packages bring significant clarity and a pattern for forms, view and
+templates.
+
+This package uses martian to configure z3c.macro based macros.
+
+Example Code
+------------
+
+::
+
+ class Navigation(mars.macro.MacroFactory):
+     """Name defaults to factory.__name__, 'navigation'"""
+     grok.template('templates/navigation.pt') # required
+     grok.context(zope.interface.Interface) # required if no module context 
+
+The following tal statement will look up the defined macro and insert its
+template.::
+
+ <div metal:use-macro="macro:naviagition" />
+
+Directives
+----------
+
+Please see ``directive.txt``.
+
+Tests
+-----
+
+See test directory.
+
+


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

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+from directive import macro, view, content_type
+from components import MacroFactory
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/components.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/components.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+class MacroFactory(object):
+    pass


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/components.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,11 @@
+from martian.directive import (InterfaceOrClassDirective,
+                               SingleTextDirective,
+                               ClassDirectiveContext)
+
+macro = SingleTextDirective('mars.macro.macro',
+                           ClassDirectiveContext())
+view = InterfaceOrClassDirective('mars.macro.view',
+                           ClassDirectiveContext())
+content_type = SingleTextDirective('mars.macro.content_type',
+                           ClassDirectiveContext())
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,53 @@
+========================
+Mars Template Directives
+========================
+
+Directives specific to this package
+-----------------------------------
+
+* mars.macro.macro(name):
+  The name of the macro to be used. This allows us to reference 
+  the named  macro defined with metal:define-macro if we use a 
+  different IMacroDirective name.
+
+* mars.macro.view(class_or_interface):
+  The view for which the macro should be used',
+  Default: IBrowserView
+
+* mars.macro.content_type(name):
+  The content type identifies the type of data.
+  Default: text/html
+
+Also the mars.layer directive may be used
+-----------------------------------------
+
+* mars.layer.layer(class_or_interface):
+  The layer for which the template should be available.
+  This directive can be used at module level
+  Default: zope.publisher.browser.interfaces.IDefaultBrowserLayer
+
+Relevant grok directives
+------------------------
+
+* grok.template(path):
+  This is used different to IGrokDirectives.template. It looks up the file
+  containing the page template using the path relative to the current module, if
+  not found it tries `path` as an absolute path, if not found GrokError is
+  raised. The file should end in extensions ``.pt`` or ``.html``.
+  **Required**
+
+* grok.name(name):
+  The macro name which this macro is registered for. The macro name can be the
+  same defined in metal:define-macro but does not have to be the same. If no
+  macro attribute is given the name is used as the name defined in
+  metal:define-macro. If you need to register a macro under a different name as
+  the defined one, you can use the macro attribute which have to reference the
+  metal.define-macro name. The TALES expression calls macros by this name and
+  returns the macro within the same name or with the name defined in the macro
+  attribute.
+  Default: or **Required**?
+
+* grok.context(class_or_interface):
+  The context for which the macro should be used. Usually should be
+  defined.
+  Default: zope.interface.Interface


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/directive.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/interfaces.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/interfaces.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/interfaces.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,23 @@
+import zope.interface
+
+class IMarsMacroDirectives(zope.interface.Interface):
+
+    def view(name):
+        """The name of the macro to be used. This allows us to reference 
+        the named  macro defined with metal:define-macro if we use a 
+        different IMacroDirective name.
+        Default: empty
+        """
+
+    def macro(name):
+        """The name of the macro to be used. This allows us to reference 
+        the named  macro defined with metal:define-macro if we use a 
+        different IMacroDirective name.
+        Default: empty
+        """
+
+    def content_type(name):
+        """The content type identifies the type of data.
+        Default: text/html
+        """
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,66 @@
+import os
+
+import zope.component
+import zope.interface
+from zope.publisher.interfaces.browser import IBrowserView
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.pagetemplate.interfaces import IPageTemplate
+
+from z3c.macro.zcml import MacroFactory
+from z3c.macro.interfaces import IMacroTemplate
+
+import martian
+from martian import util
+from martian.error import GrokError
+
+import grok
+from grok.util import check_adapts
+
+import mars.macro
+
+# TODO raise errors if anything missing?
+class MacroFactoryGrokker(martian.ClassGrokker):
+    component_class = mars.macro.MacroFactory
+
+    def grok(self, name, factory, context, module_info, templates):
+
+        view_context = util.determine_class_context(factory, context)
+
+        factory.module_info = module_info
+        factory_name = factory.__name__.lower()
+
+        # we need a path to the file containing the template
+        template_name = util.class_annotation(factory, 'grok.template',
+                                              factory_name)
+        filepath = os.path.join(os.path.dirname(module_info.path), template_name)
+        if not os.path.exists(filepath):
+            filepath = None
+            if os.path.exists(template_name):
+                filepath = template_name
+        if filepath is None:
+            raise GrokError("No template found for %s."
+                            " Please use grok.template to define path to file."
+                            " containing the template"
+                            % (factory.__name__),
+                            factory)
+
+        contentType = util.class_annotation(factory,
+                                    'mars.macro.content_type', 'text/html')
+        view_layer = util.class_annotation(factory, 'mars.layer.layer',
+                                       None) or module_info.getAnnotation('mars.layer.layer',
+                                       None) or IDefaultBrowserLayer
+
+        view_name = util.class_annotation(factory, 'grok.name', factory_name)
+        macro = util.class_annotation(factory, 'mars.macro.macro', view_name)
+        view = util.class_annotation(factory, 'mars.macro.view', IBrowserView)
+
+        factory = MacroFactory(filepath, macro, contentType)
+        #print '\nname:', view_name,'context:', view_context,\
+        #      'factory:', factory, 'view: ', view, 'layer', view_layer, '\n'
+        zope.component.provideAdapter(factory,
+                                 adapts=(view_context, view, view_layer),
+                                 provides=IMacroTemplate,
+                                 name=view_name)
+        return True
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/meta.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,68 @@
+"""
+Test the claimed directives.
+
+  >>> import grok
+  >>> grok.grok('mars.macro.tests.directive')
+
+  >>> from mars.macro.tests.directive import Mammoth
+  >>> mammoth = getRootFolder()["mammoth"] = Mammoth()
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+  >>> #browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+
+  >>> browser.open('http://localhost/mammoth/@@first')
+  >>> print browser.contents
+  <html>
+    <body>
+      <h1>First Page</h1>
+      <div class="navi">
+  <BLANKLINE>
+  <BLANKLINE>
+     <div>My Navigation</div>
+  <BLANKLINE>
+  <BLANKLINE>
+      </div>
+      <div class="content">
+        Content here
+      </div>
+    </body>
+  </html>
+  <BLANKLINE>
+
+"""
+
+import zope.component
+import zope.interface
+
+from z3c.template.interfaces import ILayoutTemplate
+
+import grok
+import mars.macro
+import mars.template
+
+class Mammoth(grok.Model):
+    pass
+
+class First(grok.View):
+
+    def __call__(self):
+        template = zope.component.getMultiAdapter(
+            (self, self.request), ILayoutTemplate)
+        return template(self)
+
+    def render(self):
+        pass
+
+class FirstLayout(mars.template.LayoutFactory):
+    grok.template('templates/first.pt')
+    grok.context(First)
+
+class MyNavigationMacro(mars.macro.MacroFactory):
+    grok.name('navigation') # define the name for macro
+    grok.template('templates/navigation.pt') # required
+    grok.context(Mammoth) # explicitly define the context
+    mars.macro.view(First) # explicitly define the view
+    mars.macro.content_type('text/html') # explicitly define content type
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,19 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+  <include package="mars.macro" file="meta.zcml" />
+
+  <include package="z3c.layer.minimal.tests" file="ftesting.zcml" />
+
+  <include package="z3c.macro" />
+  <include package="grok" />
+
+</configure>
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/macro.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/macro.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/macro.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,64 @@
+"""
+  >>> import grok
+  >>> grok.grok('mars.macro.tests.macro')
+
+  >>> from mars.macro.tests.macro import Mammoth
+  >>> mammoth = getRootFolder()["mammoth"] = Mammoth()
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+  >>> #browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+
+  >>> browser.open('http://localhost/mammoth/@@first')
+  >>> print browser.contents
+  <html>
+    <body>
+      <h1>First Page</h1>
+      <div class="navi">
+  <BLANKLINE>
+  <BLANKLINE>
+     <div>My Navigation</div>
+  <BLANKLINE>
+  <BLANKLINE>
+      </div>
+      <div class="content">
+        Content here
+      </div>
+    </body>
+  </html>
+  <BLANKLINE>
+
+"""
+
+import zope.component
+import zope.interface
+
+from z3c.template.interfaces import ILayoutTemplate
+
+import grok
+import mars.macro
+import mars.template
+
+class Navigation(mars.macro.MacroFactory):
+    """Name defaults to factory.__name__, 'navigation'"""
+    grok.template('templates/navigation.pt') # required
+    grok.context(zope.interface.Interface) # required if no module context 
+
+class Mammoth(grok.Model):
+    pass
+
+class First(grok.View):
+
+    def __call__(self):
+        template = zope.component.getMultiAdapter(
+            (self, self.request), ILayoutTemplate)
+        return template(self)
+
+    def render(self):
+        pass
+
+class FirstLayout(mars.template.LayoutFactory):
+    grok.template('templates/first.pt')
+    grok.context(First)
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/macro.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/first.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/first.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/first.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,13 @@
+<html>
+  <body>
+    <h1>First Page</h1>
+    <div class="navi">
+      <tal:block define="title string:My Navigation">
+        <metal:block use-macro="macro:navigation" />
+      </tal:block>
+    </div>
+    <div class="content">
+      Content here
+    </div>
+  </body>
+</html>

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/navigation.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/navigation.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/templates/navigation.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+<metal:block define-macro="navigation">
+   <div tal:content="title">---</div>
+</metal:block>

Added: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/test_all.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/test_all.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/test_all.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,22 @@
+import unittest
+from pkg_resources import resource_listdir
+
+from grok.ftests.test_grok_functional import FunctionalDocTestSuite
+
+from zope.app.testing import functional
+functional.defineLayer('TestLayer', 'ftesting.zcml')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    dottedname = 'mars.macro.tests.%s'
+    for name in ['directive', 'macro']:
+        test = FunctionalDocTestSuite(dottedname % name)
+        test.layer = TestLayer
+        suite.addTest(test)
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.macro/src/mars/macro/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,33 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.resource',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/mars',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to define resources and resource directories""",
+    long_description=(
+        read('src/mars/resource/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    install_requires=['setuptools',
+                      'martian',
+                      'grok',
+                     ],
+)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,31 @@
+=============
+Mars Resource
+=============
+
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+z3c packages bring significant clarity and a pattern for forms, view and
+templates.
+
+This package uses martian to configure resources and resource directories.
+
+Example Code
+------------
+
+::
+
+    Code
+
+Directives
+----------
+
+Please see ``directive.txt``.
+
+Tests
+-----
+
+See test directory.
+
+


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

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+from directive import file, image, directory
+from components import ResourceFactory, ResourceDirectoryFactory
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/components.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/components.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,6 @@
+class ResourceFactory(object):
+    pass
+
+
+class ResourceDirectoryFactory(object):
+    pass


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/components.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,12 @@
+from martian.directive import (InterfaceOrClassDirective,
+                               SingleTextDirective,
+                               ClassDirectiveContext)
+
+file = SingleTextDirective('mars.resource.file',
+                           ClassDirectiveContext())
+
+image = SingleTextDirective('mars.resource.image',
+                           ClassDirectiveContext())
+
+directory = SingleTextDirective('mars.resource.directory',
+                           ClassDirectiveContext())


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,34 @@
+========================
+Mars Template Directives
+========================
+
+Directives specific to this package
+-----------------------------------
+
+* mars.resource.file(name):
+  Path to the resource
+  **Required** one only of image or file for Resource
+
+* mars.resource.image(name):
+  Path to the resource
+  **Required** one only of image or file for Resource
+
+* mars.resource.directory(name):
+  Path to the resource directory
+  **Required** for ResourceDirectory
+
+Also the mars.layer directive may be used
+-----------------------------------------
+
+* mars.layer.layer(class_or_interface):
+  The layer for which the template should be available.
+  Default: zope.publisher.browser.interfaces.IDefaultBrowserLayer
+
+Relevant grok directives
+------------------------
+
+* grok.name(name):
+  Name by which resource or resource directory is located
+  **Required**
+
+[And possibly grok.require??]


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/directive.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/interfaces.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/interfaces.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/interfaces.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,14 @@
+import zope.interface
+
+class IMarsResourceDirectives(zope.interface.Interface):
+
+    def file(path):
+        """Path to the resource
+        Required for Resource
+        """
+
+    def directory(path):
+        """Path to the resource directory
+        Required for ResourceDirectory
+        """
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,130 @@
+import os
+
+import zope.interface
+import zope.component
+from zope.security.checker import NamesChecker, CheckerPublic
+from zope.publisher.interfaces.browser import (IBrowserRequest,
+                                                IDefaultBrowserLayer)
+from zope.app.publisher.browser.fileresource import (FileResourceFactory,
+                                                    ImageResourceFactory)
+from zope.app.publisher.browser.directoryresource import DirectoryResourceFactory
+
+import grok
+from grok.util import check_permission, get_default_permission
+
+import martian
+from martian import util
+
+import mars.resource
+allowed_names = ('GET', 'HEAD', 'publishTraverse', 'browserDefault',
+                 'request', '__call__')
+
+class ResourceGrokker(martian.ClassGrokker):
+    component_class = mars.resource.ResourceFactory
+
+    def grok(self, name, factory, context, module_info, templates):
+        factory.module_info = module_info
+        factory_name = factory.__name__.lower()
+
+        # we need a path to the file containing the resource
+        file_name = util.class_annotation(factory, 'mars.resource.file', '')
+        image_name = util.class_annotation(factory, 'mars.resource.image', '')
+        if file_name == '' and image_name == '':
+            raise GrokError("Either mars.resource.file or mars.resource.image"
+                            " must be defined for %s."
+                            % (factory.__name__),
+                            factory)
+
+        file = image = None
+        if image_name != '':
+            file_name = image_name
+            image = filepath = os.path.join(os.path.dirname(module_info.path), file_name)
+        else:
+            file = filepath = os.path.join(os.path.dirname(module_info.path), file_name)
+
+        if not os.path.exists(filepath):
+            filepath = None
+            # allow for absolute path to resource
+            if os.path.exists(file_name):
+                filepath = file_name
+        if filepath is None:
+            raise GrokError("No resource found for %s using path %s."
+                            " Please use mars.resource.file or"
+                            " mars.resource.image to define path to the"
+                            " file containing the resource"
+                            % (factory.__name__, file_name),
+                            factory)
+
+        provides = util.class_annotation(factory, 'grok.provides', IBrowserRequest)
+        view_layer = util.class_annotation(factory, 'mars.layer.layer',
+                                       None) or module_info.getAnnotation('mars.layer.layer',
+                                       None) or IDefaultBrowserLayer
+        view_name = util.class_annotation(factory, 'grok.name', '')
+
+        # protect resource, public by default
+# TODO this isn't working - the resource is always public.
+        permission = get_default_permission(factory)
+        if permission is not None:
+            check_permission(factory, permission)
+        if permission is None or permission == 'zope.Public':
+            checker = NamesChecker(allowed_names)
+        else:
+            checker = NamesChecker(allowed_names, permission)
+
+        if file:
+            factory = FileResourceFactory(file, checker, view_name)
+        elif image:
+            factory = ImageResourceFactory(image, checker, view_name)
+
+        #print '\nname:', view_name, 'factory:', factory, 'provides:', provides, '\n'
+        zope.component.provideAdapter(factory,
+                                 adapts=(view_layer, ),
+                                 provides=provides,
+                                 name=view_name)
+        return True
+
+class ResourceDirectoryGrokker(martian.ClassGrokker):
+    component_class = mars.resource.ResourceDirectoryFactory
+
+    def grok(self, name, factory, context, module_info, templates):
+        factory.module_info = module_info
+        factory_name = factory.__name__.lower()
+
+        # we need a path to the file containing the resource
+        directory_name = util.class_annotation(factory, 'mars.resource.directory', '')
+        directory = os.path.join(os.path.dirname(module_info.path), directory_name)
+
+        if not os.path.isdir(directory):
+            raise GrokError("No directory found for %s using path %s."
+                            " Please use mars.resource.directory"
+                            " to define path to the directory."
+                            % (factory.__name__, directory_name),
+                            factory)
+
+        provides = util.class_annotation(factory, 'grok.provides', IBrowserRequest)
+        view_layer = util.class_annotation(factory, 'mars.layer.layer',
+                                       None) or module_info.getAnnotation('mars.layer.layer',
+                                       None) or IDefaultBrowserLayer
+        view_name = util.class_annotation(factory, 'grok.name', factory_name)
+
+        # protect resource, public by default
+# TODO this isn't working - the resource is always public.
+        permission = get_default_permission(factory)
+        if permission is not None:
+            check_permission(factory, permission)
+        anames = allowed_names + ('__getitem__', 'get')
+        if permission is None or permission == 'zope.Public':
+            checker = NamesChecker(anames)
+        else:
+            checker = NamesChecker(anames, permission)
+
+        factory = DirectoryResourceFactory(directory, checker, view_name)
+
+        #print '\nname:', view_name, 'factory:', factory, 'provides:', provides, '\n'
+        zope.component.provideAdapter(factory,
+                                 adapts=(view_layer, ),
+                                 provides=provides,
+                                 name=view_name)
+        return True
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/meta.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,17 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+  <include package="mars.resource" file="meta.zcml" />
+
+  <include package="z3c.layer.minimal.tests" file="ftesting.zcml" />
+
+  <include package="grok" />
+
+</configure>
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resource.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resource.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resource.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,61 @@
+"""
+Test the claimed directives.
+
+  >>> import grok
+  >>> grok.grok('mars.resource.tests.resource')
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+  >>> #browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+
+These tests make use of minimal layer
+
+  >>> skinURL = 'http://localhost/++skin++myskin'
+  >>> browser.open(skinURL + '/++resource++site.css')
+  >>> print browser.contents
+  body {
+      background-color: white;
+      color: black;
+  }
+
+  >>> browser.open(skinURL + '/++resource++logo.jpg')
+
+And using the resource directory
+
+  >>> browser.open(skinURL + '/++resource++resources/site.css')
+  >>> print browser.contents
+  body {
+      background-color: white;
+      color: black;
+  }
+
+"""
+
+import grok
+import mars.resource
+import mars.layer
+
+class IMyLayer(mars.layer.IMinimalLayer):
+    pass
+
+# set layer on module level, all class declarations that use directive
+# mars.layer.layer will use this layer - Skin, views, resources and templates
+mars.layer.layer(IMyLayer)
+
+class MySkin(mars.layer.Skin):
+    pass
+
+# define a file resource
+class Style(mars.resource.ResourceFactory):
+    grok.name('site.css')
+    mars.resource.file('resources/site.css')
+
+# define an image resource
+class Logo(mars.resource.ResourceFactory):
+    grok.name('logo.jpg')
+    mars.resource.file('resources/logo.jpg')
+
+# define a resource directory, takes name from factory.__name__
+class Resources(mars.resource.ResourceDirectoryFactory):
+    mars.resource.directory('resources')


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resource.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resources/logo.jpg
===================================================================
(Binary files differ)


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resources/logo.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resources/site.css
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resources/site.css	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/resources/site.css	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,4 @@
+body {
+    background-color: white;
+    color: black;
+}

Added: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/test_all.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/test_all.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/test_all.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,22 @@
+import unittest
+from pkg_resources import resource_listdir
+
+from grok.ftests.test_grok_functional import FunctionalDocTestSuite
+
+from zope.app.testing import functional
+functional.defineLayer('TestLayer', 'ftesting.zcml')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    dottedname = 'mars.resource.tests.%s'
+    for name in ['resource']:
+        test = FunctionalDocTestSuite(dottedname % name)
+        test.layer = TestLayer
+        suite.addTest(test)
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.resource/src/mars/resource/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,33 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.template',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/martian',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to configure z3c.template based templates""",
+    long_description=(
+        read('src/mars/template/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    install_requires=['setuptools',
+                      'z3c.template',
+                      'martian',
+                     ],
+)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,40 @@
+=============
+Mars Template
+=============
+
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+z3c packages bring significant clarity and a pattern for forms, view and
+templates.
+
+This package uses martian to configure z3c.template based templates.
+
+Example Code
+------------
+
+::
+
+    class View(grok.View):
+
+        def render(self):
+            template = zope.component.getMultiAdapter(
+                (self, self.request), IPageTemplate)
+            return template(self)
+
+    class ViewTemplate(mars.template.TemplateFactory):
+        grok.template('templates/macro.pt')
+        grok.context(View)
+        mars.template.macro('mymacro')
+
+Directives
+----------
+
+Please see ``directive.txt``.
+
+Tests
+-----
+
+See test directory.
+


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

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+from directive import macro, content_type
+from components import TemplateFactory, LayoutFactory


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/components.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/components.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,8 @@
+class TemplateFactory(object):
+    pass
+
+
+class LayoutFactory(object):
+    pass
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/components.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,8 @@
+from martian.directive import (SingleTextDirective,
+                               ClassDirectiveContext)
+
+macro = SingleTextDirective('mars.template.macro',
+                           ClassDirectiveContext())
+content_type = SingleTextDirective('mars.template.content_type',
+                           ClassDirectiveContext())
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,54 @@
+========================
+Mars Template Directives
+========================
+
+Of all the available directives for registering templates only ``grok.template``
+is required to define the file containing the page template, either relative to
+the module or an absolute path.
+
+Directives specific to this package
+-----------------------------------
+
+* mars.template.macro(name):
+  The macro to be used.  This allows us to define different macros in on template.
+  The template designer can now create whole site, the ViewTemplate can then
+  extract the macros for single viewlets or views.  If no macro is given the whole
+  template is used for rendering.
+  Default: empty
+
+* mars.template.content_type(name):
+  The content type identifies the type of data.
+  Default: text/html
+
+Also the mars.layer directive may be used
+-----------------------------------------
+
+* mars.layer.layer(class_or_interface):
+  The layer for which the template should be available.
+  This directive can be used at module level
+  Default: zope.publisher.browser.interfaces.IDefaultBrowserLayer
+
+Relevant grok directives
+------------------------
+
+* grok.template(path):
+  This is used different to IGrokDirectives.template. It looks up the file
+  containing the page template using the path relative to the current module, if
+  not found it tries `path` as an absolute path, if not found GrokError is
+  raised. The file should end in extensions ``.pt`` or ``.html``.
+  **Required**
+
+* grok.name(name):
+  If defined the template will be registered as a `named adapter`.
+  Default: empty string
+
+* grok.context(class_or_interface):
+  The view for which the template should be available. Usually should be
+  defined.
+  Default: module context
+
+* grok.provides(interface):
+  Explicitly specify with which interface a component will be looked up.
+  Default: zope.pagetemplate.interfaces.IPageTemplate for TemplateFactory
+           z3c.template.interfaces.ILayoutTemplate for LayoutFactory
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/directive.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/interfaces.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/interfaces.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/interfaces.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,17 @@
+import zope.interface
+
+class IMarsTemplateDirectives(zope.interface.Interface):
+
+    def macro(name):
+        """The macro to be used.  This allows us to define different macros in on template.
+        The template designer can now create whole site, the ViewTemplate can then
+        extract the macros for single viewlets or views.  If no macro is given the whole
+        template is used for rendering.
+        Default: empty
+        """
+
+    def content_type(name):
+        """The content type identifies the type of data.
+        Default: text/html
+        """
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,74 @@
+import os
+
+import zope.component
+import zope.interface
+from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.pagetemplate.interfaces import IPageTemplate
+
+from z3c.template.template import TemplateFactory
+from z3c.template.interfaces import ILayoutTemplate
+
+import martian
+from martian import util
+from martian.error import GrokError
+
+import grok
+from grok.util import check_adapts
+
+import mars.template
+
+# TODO raise errors if anything missing?
+class TemplateFactoryGrokkerBase(martian.ClassGrokker):
+    component_class = None
+    provides = None
+
+    def grok(self, name, factory, context, module_info, templates):
+        view_context = util.determine_class_context(factory, context)
+        factory.module_info = module_info
+        factory_name = factory.__name__.lower()
+
+        # we need a path to the file containing the template
+        template_name = util.class_annotation(factory, 'grok.template',
+                                              factory_name)
+        filepath = os.path.join(os.path.dirname(module_info.path), template_name)
+        if not os.path.exists(filepath):
+            filepath = None
+            if os.path.exists(template_name):
+                filepath = template_name
+        if filepath is None:
+            raise GrokError("No template found for %s."
+                            " Please use grok.template to define path to the"
+                            " file containing the template"
+                            % (factory.__name__),
+                            factory)
+
+        provides = util.class_annotation(factory, 'grok.provides', self.provides)
+        macro = util.class_annotation(factory, 'mars.template.macro', None)
+        contentType = util.class_annotation(factory,
+                                    'mars.template.content_type', 'text/html')
+        view_layer = util.class_annotation(factory, 'mars.layer.layer',
+                                       None) or module_info.getAnnotation('mars.layer.layer',
+                                       None) or IDefaultBrowserLayer
+        view_name = util.class_annotation(factory, 'grok.name', '')
+
+        factory = TemplateFactory(filepath, contentType, macro)
+        zope.interface.directlyProvides(factory, provides)
+        #print '\nname:', view_name,'context:', view_context,'factory:',\
+        #      factory, 'provides', provides, '\n'
+        zope.component.provideAdapter(factory,
+                                 adapts=(view_context, view_layer),
+                                 provides=provides,
+                                 name=view_name)
+        return True
+
+
+class TemplateFactoryGrokker(TemplateFactoryGrokkerBase):
+    component_class = mars.template.TemplateFactory
+    provides = IPageTemplate
+
+class LayoutFactoryGrokker(TemplateFactoryGrokkerBase):
+    component_class = mars.template.LayoutFactory
+    provides = ILayoutTemplate
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/meta.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,70 @@
+"""
+Run through and test the available directives to template factories.
+
+  >>> import grok
+  >>> from mars.template.tests.directive import Mammoth
+  >>> grok.grok('mars.template.tests.directive')
+
+  >>> mammoth = getRootFolder()["mammoth"] = Mammoth()
+
+Layout views have a call method (TemplateViews do not necessarily) so we will
+use testbrowser.
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+
+  >>> browser.open("http://localhost/++skin++myskin/mammoth/@@view")
+  >>> #browser.open("http://localhost/mammoth/@@view")
+  >>> print browser.contents
+  <body>
+  <div>Rendered content</div>
+  </body>
+
+"""
+# TODO add layer directive, when you have a view grokker to use
+
+
+import zope.component
+import zope.interface
+
+from z3c.template.interfaces import ILayoutTemplate
+
+import grok
+from grok.interfaces import IGrokView
+
+import mars.template
+import mars.layer
+import mars.view
+
+class IMyLayer(mars.layer.IMinimalLayer):
+    pass
+
+class MySkin(mars.layer.Skin):
+    mars.layer.layer(IMyLayer)
+
+class IMyPageTemplate(zope.interface.Interface):
+    pass
+
+class Mammoth(grok.Model):
+    pass
+
+class View(mars.view.LayoutView):
+    """Here use LayoutView which uses layers"""
+    mars.layer.layer(IMyLayer)
+    mars.view.layout('complex') # forces named layout template lookup
+    _layout_interface = IMyPageTemplate # if template provides specific interface
+
+    def render(self):
+        return u'Rendered content'
+
+class ViewLayout(mars.template.LayoutFactory):
+    grok.template('templates/complex.pt') # required
+    grok.context(View) # define the adapted view
+    grok.name('complex') # view must use named adapter lookup
+    grok.provides(IMyPageTemplate) # view must use this interface to lookup
+    mars.template.macro('body') # define the macro to use
+    mars.template.content_type('text/html') # define the contentType
+    mars.layer.layer(IMyLayer) # registered on this layer.
+    
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,67 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+  <include package="mars.view" file="meta.zcml" />
+
+  <include package="zope.app.zcmlfiles" />
+
+  <!-- -->
+  <!-- -->
+
+  <include package="zope.app.securitypolicy" file="meta.zcml" />
+  <include package="zope.app.authentication" />
+  <securityPolicy
+    component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+  <include package="zope.app.securitypolicy" />
+
+  <role id="zope.Anonymous" title="Everybody"
+        description="All users have this role implicitly" />
+
+  <role id="zope.Manager" title="Site Manager" />
+
+  <principal
+   id="zope.manager"
+   title="Administrator"
+   login="mgr"
+   password="mgrpw" />
+
+  <grant
+   role="zope.Manager"
+   principal="zope.manager"
+   />
+
+  <unauthenticatedPrincipal
+    id="zope.anybody"
+    title="Unauthenticated User" />
+
+  <unauthenticatedGroup
+    id="zope.Anybody"
+    title="Unauthenticated Users"
+    />
+
+  <authenticatedGroup
+    id="zope.Authenticated"
+    title="Authenticated Users"
+    />
+
+  <everybodyGroup
+    id="zope.Everybody"
+    title="All Users"
+    />
+
+  <grantAll role="zope.Manager" />
+
+
+  <include package="grok" />
+
+</configure>
+
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/layout.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/layout.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/layout.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,90 @@
+"""
+LayoutFactories allow use to define page templates in python code.
+
+  >>> import grok
+  >>> from mars.template.tests.layout import Mammoth
+  >>> grok.grok('mars.template.tests.layout')
+
+  >>> mammoth = getRootFolder()["mammoth"] = Mammoth()
+
+Layout views have a call method (TemplateViews do not necessarily) so we will
+use testbrowser.
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+
+  >>> browser.open("http://localhost/mammoth/@@view")
+  >>> print browser.contents
+  <div>View template</div>
+
+Like TemplateFactories, LayoutFactories also support a `macro` directive (see z3c.template).
+
+  >>> browser.open("http://localhost/mammoth/@@macro")
+  >>> print browser.contents
+  <div>This is within the mymacro macro</div>
+
+And also allow the setting of the contentType. But I haven't got that to render yet.
+
+  >>> import zope.component
+  >>> from z3c.template.interfaces import ILayoutTemplate
+  >>> from mars.template.tests.layout import PlainText
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> plaintext = PlainText(mammoth, request)
+  >>> template = zope.component.getMultiAdapter(
+  ...              (plaintext, request), ILayoutTemplate)
+  >>> print template.content_type
+  text/plain
+
+"""
+
+import zope.component
+import zope.interface
+
+from z3c.template.interfaces import ILayoutTemplate
+
+import grok
+
+import mars.template
+
+class Mammoth(grok.Model):
+    pass
+
+class LayoutView(grok.View):
+
+    def __call__(self):
+        template = zope.component.getMultiAdapter(
+            (self, self.request), ILayoutTemplate)
+        return template(self)
+
+    def render(self):
+        pass
+
+class View(LayoutView):
+    pass
+
+class ViewLayout(mars.template.LayoutFactory):
+    grok.template('templates/view.pt')
+    grok.context(View) # this is template for View 
+
+class Macro(LayoutView):
+    pass
+
+class MacroLayout(mars.template.LayoutFactory):
+    grok.template('templates/macro.pt')
+    grok.context(Macro)
+    mars.template.macro('mymacro')
+
+class PlainText(LayoutView):
+    pass
+
+class PlainTextLayout(mars.template.LayoutFactory):
+    grok.template('templates/plain.pt')
+    grok.context(PlainText)
+    mars.template.content_type('text/plain')
+
+
+
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/layout.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/minimal-ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/minimal-ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/minimal-ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,17 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+  <include package="mars.view" file="meta.zcml" />
+
+  <include package="z3c.layer.minimal.tests" file="ftesting.zcml" />
+
+  <include package="grok" />
+
+</configure>
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/template.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/template.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/template.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,86 @@
+"""
+TemplateFactories allow use to define page templates in python code.
+
+  >>> import grok
+  >>> from mars.template.tests.template import Mammoth
+  >>> grok.grok('mars.template.tests.template')
+
+  >>> mammoth = Mammoth()
+  >>> import zope.component
+  >>> from zope.pagetemplate.interfaces import IPageTemplate
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> from mars.template.tests.template import View
+  >>> view = View(mammoth, request)
+
+The template can then be looked up for the object that it is registered for
+using grok.context.
+
+  >>> template = zope.component.getMultiAdapter(
+  ...              (view, request), IPageTemplate)
+  >>> print template
+  <zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile object at ...>
+
+  >>> print view.render()
+  <div>View template</div>
+
+TemplateFactories support a `macro` directive (see z3c.template).
+
+  >>> from mars.template.tests.template import Macro
+  >>> macro = Macro(mammoth, request)
+  >>> print macro.render()
+  <div>This is within the mymacro macro</div>
+
+TemplateFactories also allow the setting of the contentType.
+
+  >>> from mars.template.tests.template import PlainText
+  >>> plaintext = PlainText(mammoth, request)
+  >>> template = zope.component.getMultiAdapter(
+  ...              (plaintext, request), IPageTemplate)
+  >>> print template.content_type
+  text/plain
+
+"""
+
+import zope.component
+from zope.pagetemplate.interfaces import IPageTemplate
+
+import grok
+
+import mars.template
+
+class Mammoth(grok.Model):
+    pass
+
+class TemplateView(grok.View):
+
+    def render(self):
+        template = zope.component.getMultiAdapter(
+            (self, self.request), IPageTemplate)
+        return template(self)
+
+class View(TemplateView):
+    pass
+
+class ViewTemplate(mars.template.TemplateFactory):
+    grok.template('templates/view.pt')
+    grok.context(View) # this is template for View 
+
+class Macro(TemplateView):
+    pass
+
+class MacroTemplate(mars.template.TemplateFactory):
+    grok.template('templates/macro.pt')
+    grok.context(Macro)
+    mars.template.macro('mymacro')
+
+class PlainText(TemplateView):
+    pass
+
+class PlainTextTemplate(mars.template.TemplateFactory):
+    grok.template('templates/plain.pt')
+    grok.context(PlainText)
+    mars.template.content_type('text/plain')
+
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/template.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/complex.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/complex.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/complex.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,5 @@
+<html>
+<body metal:define-macro="body">
+<div tal:content="view/render" />
+</body>
+</html>

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/macro.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/macro.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/macro.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,4 @@
+<div>This won't be rendered</div>
+<div metal:define-macro="mymacro">This is within the mymacro macro</div>
+<div>This won't be rendered</div>
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/plain.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/plain.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/plain.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+Plain text

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/view.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/view.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/templates/view.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+<div>View template</div>

Added: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/test_all.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/test_all.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/test_all.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,32 @@
+import unittest
+from pkg_resources import resource_listdir
+
+from grok.ftests.test_grok_functional import FunctionalDocTestSuite
+
+from zope.app.testing import functional
+
+from martian.tests.test_all import globs, optionflags
+
+functional.defineLayer('TestLayer', 'ftesting.zcml')
+functional.defineLayer('TestMinimalLayer', 'minimal-ftesting.zcml')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    dottedname = 'mars.template.tests.%s'
+
+    for name in ['template', 'layout']:
+        test = FunctionalDocTestSuite(dottedname % name)
+        test.layer = TestLayer
+        suite.addTest(test)
+
+    test = FunctionalDocTestSuite(dottedname % 'directive')
+    test.layer = TestMinimalLayer
+    suite.addTest(test)
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.template/src/mars/template/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,33 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.view',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/martian',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to define views""",
+    long_description=(
+        read('src/mars/view/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    install_requires=['setuptools',
+                      'martian',
+                      'grok',
+                     ],
+)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,69 @@
+=========
+Mars View
+=========
+
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+z3c packages bring significant clarity and a pattern for forms, view and
+templates.
+
+This package uses martian to configure views. The views here defined are
+TemplateView and LayoutView, both use adapter lookup to locate the template to
+be used (but can class attributes `template` for TemplateView and LayoutView and `layout` for
+LayoutView will be used before adapter lookup).
+
+TemplateView provides only a `render` method which returns the rendered
+template.
+
+LayoutView has a `__call__` method that returns the rendered layout template in
+addition to a `render` method inherited from TemplateView which returns the
+rendered template.
+
+Example Code
+------------
+
+The following registers a view for Context named view. It has a
+`render` method that renders the template defined by ViewTemplate::
+
+ class Context(grok.Model):
+     pass
+
+ class View(mars.view.TemplateView):
+     pass
+
+ class ViewTemplate(mars.template.TemplateFactory):
+     grok.template('templates/template.pt')
+     grok.context(View)
+
+The following snippet registers a view for Context named view. It has a
+`__call__` method that renders the template defined by ViewLayout in addition to a
+`render` method that renders the template defined by ViewTemplate::
+
+ class Context(grok.Model):
+     pass
+
+ class View(mars.view.LayoutView):
+     pass
+
+ class ViewLayout(mars.template.LayoutFactory):
+     grok.template('templates/template.pt')
+     grok.context(View)
+
+ class ViewSnippet(mars.template.TemplateFactory):
+     grok.template('templates/snippet.pt')
+     grok.context(View)
+
+
+Directives
+----------
+
+Please see ``directive.txt``.
+
+Tests
+-----
+
+See test directory.
+
+


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

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+from directive import layout
+from components import TemplateView, LayoutView, PageletView, FormView
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,136 @@
+import zope.component
+import zope.interface
+from zope.component.interfaces import ComponentLookupError
+from zope.publisher.browser import BrowserPage
+from zope.publisher.publish import mapply
+from zope.pagetemplate.interfaces import IPageTemplate
+
+from z3c.template.interfaces import ILayoutTemplate
+from z3c.pagelet.interfaces import IPagelet
+
+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
+    _template_name = u'' # will be set if grok.template defined
+    _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)
+        if template is None:
+            template = zope.component.getMultiAdapter(
+                (self, self.request), self._template_interface, 
+                name=self._template_name)
+            return template(self)
+        return template(self)
+
+
+class TemplateView(ViewBase, TemplateViewBase, BrowserPage):
+
+    def __init__(self, context, request):
+        super(TemplateView, self).__init__(context, request)
+
+
+class LayoutViewBase(object):
+    layout = None
+    _layout_name = u'' # will be set if mars.view.layout defined
+    _layout_interface = ILayoutTemplate
+
+    def __call__(self):
+        if not self._updated: # may already be called in render method
+            mapply(self.update, (), self.request)
+        if self.request.response.getStatus() in (302, 303):
+            return
+        layout = getattr(self, 'layout', None)
+        if layout is None:
+            layout = zope.component.getMultiAdapter(
+                    (self, self.request), self._layout_interface, 
+                    name=self._layout_name)
+            return layout(self)
+        return layout(self)
+
+class LayoutView(ViewBase, LayoutViewBase, BrowserPage):
+
+    def __init__(self, context, request):
+        super(LayoutView, self).__init__(context, request)
+
+class PageletView(ViewBase, TemplateViewBase, LayoutViewBase, BrowserPage):
+    zope.interface.implements(IPagelet)
+
+    def __init__(self, context, request):
+        super(PageletView, self).__init__(context, request)
+
+class FormView(object):
+    """Vanilla view to mixin with z3c.form views"""
+    zope.interface.implements(IPagelet)


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/components.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,4 @@
+from martian.directive import (SingleTextDirective,
+                               ClassDirectiveContext)
+
+layout = SingleTextDirective('mars.view.layout', ClassDirectiveContext())


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,47 @@
+========================
+Mars Template Directives
+========================
+
+Directives specific to this package
+-----------------------------------
+
+* mars.view.layout(name):
+  If defined the layout for LayoutView will be looked up as a `named adapter`.
+  Should only be defined if the layout template has been registered as a named
+  adapter.
+  Default: ''
+
+
+The mars.layer directive may be used
+-----------------------------------------
+
+* mars.layer.layer(class_or_interface):
+  The layer for which the template should be available.
+  Default: zope.publisher.browser.interfaces.IDefaultBrowserLayer
+
+Relevant grok directives
+------------------------
+
+* grok.name(name):
+  Name of the view, available in url as object/@@viewname.
+  Default: factory.__name__.lower()
+
+* grok.context(class_or_interface):
+  The view for which the template should be available. Usually should be
+  defined.
+  Default: module context
+
+* grok.template(name):
+  If defined the template will be looked up as a `named adapter`. Should only be
+  defined if the template has been registered as a named adapter.
+  Default: ''
+
+* grok.require(permission):
+  Protect the view class with ``permission``.
+  ``permission`` must already be defined, e.g. using
+  grok.define_permission.
+  Default: []
+
+* grok.provides(class_or_interface):
+  Interface the class is looked up as, probably wouldn't be used.
+  Default: zope.interface.Interface


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/directive.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/interfaces.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/interfaces.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/interfaces.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,11 @@
+import zope.interface
+
+class IMarsViewDirectives(zope.interface.Interface):
+
+    def layout(name):
+        """Declare the layout name for a view.
+        If defined the layout will be looked up as a named adapter.
+        Should only be defined if the layout template has been registered as a named
+        adapter.
+        """
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,124 @@
+import zope.component
+import zope.interface
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+
+from z3c.template.template import TemplateFactory
+
+import martian
+from martian.error import GrokError
+from martian import util
+
+import grok
+from grok.util import get_default_permission, make_checker
+
+import mars.view
+
+class ViewGrokkerBase(martian.ClassGrokker):
+    """Code resuse for View, ContentProvider and Viewlet grokkers"""
+    component_class = None
+    factory_name = ''
+    view_name = ''
+    layer_name = ''
+    view_context = None
+    provides = zope.interface.Interface
+
+    def grok(self, name, factory, context, module_info, templates):
+        self.view_context = util.determine_class_context(factory, context)
+        factory.module_info = module_info
+        self.factory_name = factory.__name__.lower()
+
+        self.view_layer = util.class_annotation(factory, 'mars.layer.layer',
+                                           None) or module_info.getAnnotation('mars.layer.layer',
+                                               None) or IDefaultBrowserLayer
+
+        self.view_name = util.class_annotation(factory, 'grok.name',
+                                          self.factory_name)
+
+        # is name defined for template?
+        # if defined a named template is looked up
+        factory._template_name = util.class_annotation(factory, 'grok.template', '')
+
+        # __view_name__ is needed to support IAbsoluteURL on views
+        # TODO check how this is working for these views
+        factory.__view_name__ = self.view_name
+
+        # don't know if this would ever need to be set
+        self.provides = util.class_annotation(factory, 'grok.provides',
+                                                self.provides)
+        #print '\nname:', self.view_name,'context:', self.view_context,'factory:', factory,\
+        #      'layer:', self.view_layer, '\n'
+        self.register(factory, module_info)
+
+        # protect view, public by default
+        default_permission = get_default_permission(factory)
+        make_checker(factory, factory, default_permission)
+
+        # 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 getattr(method, '__grok_require__', None) 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)
+
+        return True
+
+    def register(self, factory, module_info):
+        """Must be defined in subclasses, module_info may be necessary for further lookups"""
+        pass
+
+
+class TemplateViewGrokker(ViewGrokkerBase):
+    component_class = mars.view.TemplateView
+
+    def register(self, factory, module_info):
+
+        zope.component.provideAdapter(factory,
+                                 adapts=(self.view_context, self.view_layer),
+                                 provides=self.provides,
+                                 name=self.view_name)
+
+class LayoutViewGrokker(ViewGrokkerBase):
+    component_class = mars.view.LayoutView
+
+    def register(self, factory, module_info):
+
+        # is name defined for layout?
+        # if defined a named template is looked up
+        factory._layout_name = util.class_annotation(factory, 'mars.view.layout', '')
+
+        zope.component.provideAdapter(factory,
+                                 adapts=(self.view_context, self.view_layer),
+                                 provides=self.provides,
+                                 name=self.view_name)
+
+class PageletViewGrokker(ViewGrokkerBase):
+    component_class = mars.view.PageletView
+
+    def register(self, factory, module_info):
+
+        # is name defined for layout?
+        # if defined a named template is looked up
+        factory._layout_name = util.class_annotation(factory, 'mars.view.layout', '')
+
+        zope.component.provideAdapter(factory,
+                                 adapts=(self.view_context, self.view_layer),
+                                 provides=self.provides,
+                                 name=self.view_name)
+
+class FormViewGrokker(ViewGrokkerBase):
+    component_class = mars.view.FormView
+
+    def register(self, factory, module_info):
+
+        # is name defined for layout?
+        # if defined a named template is looked up
+        factory._layout_name = util.class_annotation(factory, 'mars.view.layout', '')
+
+        zope.component.provideAdapter(factory,
+                                 adapts=(self.view_context, self.view_layer),
+                                 provides=self.provides,
+                                 name=self.view_name)
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/meta.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,15 @@
+"""
+Test the claimed directives.
+
+  >>> import grok
+  >>> grok.grok('mars.view.tests.directive')
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+
+"""
+
+import grok
+import mars.view
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,18 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+  <include package="mars.view" file="meta.zcml" />
+
+  <include package="z3c.layer.minimal.tests" file="ftesting.zcml" />
+
+  <include package="grok" />
+
+</configure>
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/layout.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/layout.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/layout.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,95 @@
+"""
+Testing the LayoutView, which unlike grok.View will look up a layout.
+
+  >>> import grok
+  >>> grok.grok('mars.view.tests.layout')
+  >>> from mars.view.tests.layout import Mammoth
+  >>> getRootFolder()["manfred"] = Mammoth()
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+
+These tests make use of minimal layer
+
+  >>> skinURL = 'http://localhost/++skin++myskin'
+
+Since a layout template is not yet registered, calling the view will fail:
+
+  >>> browser.open("http://localhost/manfred/@@drawing")
+  Traceback (most recent call last):
+  ...
+  NotFound: ......
+
+  >>> browser.open(skinURL + "/manfred/@@drawing")
+  Traceback (most recent call last):
+  ...
+  ComponentLookupError: ......
+
+We'll manually register a layout template.
+
+  >>> import os, tempfile
+  >>> temp_dir = tempfile.mkdtemp()
+  >>> layout = os.path.join(temp_dir, 'layout.pt')
+  >>> open(layout, 'w').write('''
+  ...   <div tal:content="view/render">
+  ...     Full layout
+  ...   </div>
+  ... ''')
+
+  >>> from z3c.template.interfaces import ILayoutTemplate
+  >>> from z3c.template.template import TemplateFactory
+  >>> from zope.publisher.interfaces.browser import IBrowserRequest
+  >>> import zope.component
+  >>> from mars.view.tests.layout import Drawing
+  >>> factory = TemplateFactory(layout, 'text/html')
+  >>> zope.component.provideAdapter(factory,
+  ...     (Drawing, IBrowserRequest), ILayoutTemplate)
+
+  >>> browser.open(skinURL + "/manfred/@@drawing")
+  >>> print browser.contents
+  <div>Rendered content</div>
+
+  >>> import shutil
+  >>> shutil.rmtree(temp_dir)
+
+We can also use mars.template to provide the layout template.
+
+  >>> browser.open(skinURL + "/manfred/@@view")
+  >>> print browser.contents
+  <div>View template</div>
+
+"""
+import zope.interface
+
+import grok
+import mars.view
+import mars.template
+import mars.layer
+
+class IMyLayer(mars.layer.IMinimalLayer):
+    pass
+
+# set layer on module level, all class declarations that use directive
+# mars.layer.layer will use this layer - Skin, views and templates
+mars.layer.layer(IMyLayer)
+
+class MySkin(mars.layer.Skin):
+    pass
+
+class Mammoth(grok.Model):
+    pass
+
+class Drawing(mars.view.LayoutView):
+    pass
+
+    def render(self):
+        return u'Rendered content'
+
+class View(mars.view.LayoutView):
+    pass
+
+class ViewLayout(mars.template.LayoutFactory):
+    grok.template('templates/template.pt')
+    grok.context(View)
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/layout.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/pagelet.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/pagelet.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/pagelet.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,58 @@
+"""
+Testing the PageletView, which unlike grok.View will look up a layout.
+
+  >>> import grok
+  >>> grok.grok('mars.view.tests.pagelet')
+  >>> from mars.view.tests.pagelet import Mammoth
+  >>> getRootFolder()["manfred"] = Mammoth()
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+
+These tests make use of minimal layer
+
+  >>> skinURL = 'http://localhost/++skin++myskin'
+
+Pagelet will use two templates, one rendered and returned from ``render`` method
+and the second - a layout template - on ``__call__`` method.
+
+  >>> browser.open(skinURL + "/manfred/@@full")
+  >>> print browser.contents
+  <html>
+  <body><div>View template</div>
+  </body>
+  </html>
+
+"""
+import zope.interface
+
+import grok
+import mars.view
+import mars.template
+import mars.layer
+
+class IMyLayer(mars.layer.IMinimalLayer):
+    pass
+
+# set layer on module level, all class declarations that use directive
+# mars.layer.layer will use this layer - Skin, views and templates
+mars.layer.layer(IMyLayer)
+
+class MySkin(mars.layer.Skin):
+    pass
+
+class Mammoth(grok.Model):
+    pass
+
+class Full(mars.view.PageletView):
+    pass
+
+class FullLayout(mars.template.LayoutFactory):
+    grok.template('templates/layout.pt')
+    grok.context(Full)
+
+class FullTemplate(mars.template.TemplateFactory):
+    grok.template('templates/template.pt')
+    grok.context(Full)
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/pagelet.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/template.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/template.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/template.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,75 @@
+"""
+Testing the TemplateView, which unlike grok.View will look up a template.
+
+  >>> import grok
+  >>> from mars.view.tests.template import Mammoth, Painting
+  >>> grok.grok('mars.view.tests.template')
+  >>> mammoth = getRootFolder()["manfred"] = Mammoth()
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+
+TemplateViews look up a template as an adpater.
+
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> view = Painting(mammoth, request)
+  >>> from zope.publisher.interfaces.browser import IBrowserView
+
+Since a template is not yet registered, rendering the view will fail:
+
+  >>> print view.render()
+  Traceback (most recent call last):
+  ...
+  ComponentLookupError: ......
+
+We can register a template for the view.
+
+  >>> import os, tempfile
+  >>> temp_dir = tempfile.mkdtemp()
+  >>> from zope.pagetemplate.interfaces import IPageTemplate
+  >>> from z3c.template.template import TemplateFactory
+  >>> from zope.publisher.interfaces.browser import IBrowserRequest
+  >>> import zope.component
+  >>> template = os.path.join(temp_dir, 'template.pt')
+  >>> open(template, 'w').write('''
+  ...   <div>Rendered content</div>
+  ... ''')
+
+  >>> factory = TemplateFactory(template, 'text/html')
+  >>> zope.component.provideAdapter(factory,
+  ...     (Painting, IBrowserRequest), IPageTemplate)
+
+  >>> print view.render()
+  <div>Rendered content</div>
+
+  >>> import shutil
+  >>> shutil.rmtree(temp_dir)
+
+We can also use mars.template to provide the template.
+
+  >>> from mars.view.tests.template import View
+  >>> view = View(mammoth, request)
+  >>> print view.render()
+  <div>View template</div>
+
+"""
+import grok
+import mars.view
+import mars.template
+
+class Mammoth(grok.Model):
+    pass
+
+class Painting(mars.view.TemplateView):
+    pass
+
+class View(mars.view.TemplateView):
+    pass
+
+class ViewTemplate(mars.template.TemplateFactory):
+    grok.template('templates/template.pt')
+    grok.context(View)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/template.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/layout.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/layout.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/layout.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+<html>
+<body tal:content="structure view/render" />
+</html>

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/template.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/template.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/templates/template.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+<div>View template</div>

Added: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/test_all.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/test_all.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/test_all.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,22 @@
+import unittest
+from pkg_resources import resource_listdir
+
+from grok.ftests.test_grok_functional import FunctionalDocTestSuite
+
+from zope.app.testing import functional
+functional.defineLayer('TestLayer', 'ftesting.zcml')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    dottedname = 'mars.view.tests.%s'
+    for name in ['layout', 'template', 'pagelet']:
+        test = FunctionalDocTestSuite(dottedname % name)
+        test.layer = TestLayer
+        suite.addTest(test)
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.view/src/mars/view/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,34 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.viewlet',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/martian',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to define viewlets and viewlet managers""",
+    long_description=(
+        read('src/mars/viewlet/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    install_requires=['setuptools',
+                      'martian',
+                      'zope.viewlet',
+                      'z3c.viewlet',
+                     ],
+)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,29 @@
+==========
+Mars Macro
+==========
+
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+z3c packages bring significant clarity and a pattern for forms, view and
+templates.
+
+This package uses martian to configure viewlets and viewletmanagers.
+
+Example Code
+------------
+
+Please see ./tests/viewlet.py
+
+Directives
+----------
+
+Please see ``directive.txt``.
+
+Tests
+-----
+
+See test directory.
+
+


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

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+from directive import manager, view
+from components import Viewlet, ViewletManager, SimpleViewlet


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,66 @@
+import zope.interface
+from zope.component.interfaces import ComponentLookupError
+from zope.publisher.browser import BrowserView
+from zope.publisher.publish import mapply
+from zope.viewlet.interfaces import IViewlet, IViewletManager
+
+from z3c.viewlet.manager import WeightOrderedViewletManager
+
+from martian import util
+
+from mars.view.components import TemplateViewBase, ViewBase
+
+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):
+    zope.interface.implements(IViewlet)
+
+    def __init__(self, context, request, view, manager):
+        self.__parent__ = self.view = view
+        self.context = context
+        self.request = request
+        self.manager = manager
+
+class ViewletManager(WeightOrderedViewletManager, ViewBase, TemplateViewBase):
+    zope.interface.implements(IViewletManager)
+
+    def __init__(self, context, request, view):
+        self.__updated = False
+        self.__parent__ = self.view = view
+        self.context = context
+        self.request = request
+
+    def render(self):
+        """Allows template rendering before falling back to the viewlets"""
+        template = getattr(self, 'template', None)
+        if template is not None:
+            return template(self)
+        else:
+            try:
+                template = zope.component.getMultiAdapter(
+                    (self, self.request), self._template_interface, 
+                    name=self._template_name)
+                return template(self)
+            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
+
+        ``viewlets`` is a list of tuples of the form (name, viewlet).
+        """
+# this is the original for z.v.manager.py but I would get ForbiddenAttribute: ('render'
+# for the viewlets, I need to go a step and create security checkers on viewlets
+# as on Views
+        # Only return viewlets accessible to the principal
+        #import zope.security
+        #return [(name, viewlet) for name, viewlet in viewlets
+        #                        if zope.security.canAccess(viewlet, 'render')]
+        return [(name, viewlet) for name, viewlet in viewlets]


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/components.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+from martian.directive import (InterfaceOrClassDirective,
+                               ClassDirectiveContext)
+
+manager = InterfaceOrClassDirective('mars.viewlet.manager',
+                           ClassDirectiveContext())
+view = InterfaceOrClassDirective('mars.viewlet.view',
+                           ClassDirectiveContext())


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,43 @@
+=======================
+Mars Viewlet Directives
+=======================
+
+Directives specific to this package
+-----------------------------------
+
+* mars.viewlet.manager(class_or_interface):
+  The manager for which the viewlet is registered.
+  Default: IViewletManager (?)
+
+* mars.viewlet.view(class_or_interface):
+  The view for which the viewlet is registered.
+  Default: zope.publisher.interfaces.browser.IBrowserView
+
+
+The mars.layer directive may be used
+-----------------------------------------
+
+* mars.layer.layer(class_or_interface):
+  The layer for which the template should be available.
+  Default: zope.publisher.browser.interfaces.IDefaultBrowserLayer
+
+Relevant grok directives
+------------------------
+
+* grok.name(name):
+  Name of the view, available in url as object/@@viewname.
+  Default: factory.__name__.lower()
+
+* grok.context(class_or_interface):
+  The view for which the template should be available. Usually should be
+  defined.
+  Default: module context
+
+* grok.template(name):
+  If defined the template will be looked up as a `named adapter`. Should only be
+  defined if a template has been registered as a named adapter.
+  Default: ''
+
+* grok.provides(class_or_interface):
+  Interface the class is looked up as, probably wouldn't be used.
+  Default: zope.interface.Interface


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/directive.txt
___________________________________________________________________
Name: svn:keywords
   + Date Author

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/interfaces.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/interfaces.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/interfaces.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,13 @@
+import zope.interface
+
+class IMarsViewletDirectives(zope.interface.Interface):
+
+    def manager(class_or_interface):
+        """The manager for which the viewlet is registered
+        Default: zope.viewlet.interfaces.IViewletManager
+        """
+
+    def view(class_or_interface):
+        """The view for which the viewlet is registered
+        Default: zope.publisher.browser.interfaces.IBrowserView
+        """


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,64 @@
+import zope.component
+from zope.publisher.interfaces.browser import IBrowserView
+
+from zope.viewlet.interfaces import IViewlet, IViewletManager
+
+from martian import util
+
+import mars.viewlet
+from mars.view.meta import ViewGrokkerBase
+
+class ViewletManagerGrokker(ViewGrokkerBase):
+    component_class = mars.viewlet.ViewletManager
+    provides = IViewletManager
+    
+    def register(self, factory, module_info):
+
+        #print '\nname:', self.view_name,'context:', self.view_context,'factory:', factory,\
+        #      'layer:', self.view_layer, 'provides', self.provides, '\n'
+        zope.component.provideAdapter(factory,
+                     adapts=(self.view_context, self.view_layer, IBrowserView),
+                     provides=self.provides,
+                     name=self.view_name)
+
+
+class ViewletGrokker(ViewGrokkerBase):
+    component_class = mars.viewlet.Viewlet
+
+    def register(self, factory, module_info):
+
+        manager = util.class_annotation(factory, 'mars.viewlet.manager',
+                       None) or module_info.getAnnotation('mars.viewlet.manager',
+                       None) or IViewletManager # IViewletManager?
+
+        view = util.class_annotation(factory, 'mars.viewlet.view',
+                       None) or IBrowserView
+#        print '\nname:', self.view_name,'context:', self.view_context,'factory:', factory,\
+#              'layer:', self.view_layer, 'manager', manager, 'view: ', view,'\n'
+        zope.component.provideAdapter(factory,
+                                 adapts=(self.view_context, self.view_layer, 
+                                         view, manager),
+                                 provides=IViewlet,
+                                 name=self.view_name)
+
+
+class SimpleViewletGrokker(ViewGrokkerBase):
+    component_class = mars.viewlet.SimpleViewlet
+
+    def register(self, factory, module_info):
+
+        manager = util.class_annotation(factory, 'mars.viewlet.manager',
+                       None) or module_info.getAnnotation('mars.viewlet.manager',
+                       None) or IViewletManager # IViewletManager?
+
+        view = util.class_annotation(factory, 'mars.viewlet.view',
+                       None) or IBrowserView
+#        print '\nname:', self.view_name,'context:', self.view_context,'factory:', factory,\
+#              'layer:', self.view_layer, 'manager', manager, 'view: ', view,'\n'
+        zope.component.provideAdapter(factory,
+                                 adapts=(self.view_context, self.view_layer, 
+                                         view, manager),
+                                 provides=IViewlet,
+                                 name=self.view_name)
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/meta.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,2 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,21 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           i18n_domain="zope"
+           package="mars.template.tests">
+
+  <include package="grok" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.layer" file="meta.zcml" />
+  <include package="mars.macro" file="meta.zcml" />
+  <include package="mars.view" file="meta.zcml" />
+  <include package="mars.viewlet" file="meta.zcml" />
+
+  <include package="z3c.layer.minimal.tests" file="ftesting.zcml" />
+
+  <include package="zope.contentprovider" />
+  <include package="grok" />
+
+</configure>
+
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/index.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/index.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/index.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,11 @@
+<html>
+<body>
+<div id="leftcolumn">
+<tal:block tal:content="structure provider:leftcolumn" />
+</div>
+<div id="rightcolumn">
+<tal:block tal:content="structure provider:rightcolumn" />
+</div>
+</body>
+</html>
+

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/test_all.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/test_all.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/test_all.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,22 @@
+import unittest
+from pkg_resources import resource_listdir
+
+from grok.ftests.test_grok_functional import FunctionalDocTestSuite
+
+from zope.app.testing import functional
+functional.defineLayer('TestLayer', 'ftesting.zcml')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    dottedname = 'mars.viewlet.tests.%s'
+    for name in ['viewlet']:
+        test = FunctionalDocTestSuite(dottedname % name)
+        test.layer = TestLayer
+        suite.addTest(test)
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+<div>Second viewlet content</div>

Added: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,89 @@
+"""
+
+  >>> import grok
+  >>> grok.grok('mars.viewlet.tests.viewlet')
+  >>> from mars.viewlet.tests.viewlet import Mammoth
+  >>> getRootFolder()["manfred"] = Mammoth()
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.handleErrors = False
+  >>> skinURL = 'http://localhost/++skin++myskin'
+  >>> browser.open(skinURL + "/manfred/@@index")
+  >>> print browser.contents
+  <html>
+  <body>
+  <div id="leftcolumn">
+  <div>First viewlet content</div>
+  <div>Second viewlet content</div>
+  <BLANKLINE>
+  </div>
+  <div id="rightcolumn">
+  Right column content
+  </div>
+  </body>
+  </html>
+
+"""
+import grok
+import mars.layer
+import mars.viewlet
+import mars.view
+import mars.template
+
+### This the context of the views
+class Mammoth(grok.Model):
+    title = u'Manfred'
+
+### define a layer that will be used for all views in this module
+class IModuleLayer(mars.layer.IMinimalLayer):
+    pass
+
+mars.layer.layer(IModuleLayer)
+
+### this skin uses the defined layer
+class MySkin(mars.layer.Skin):
+    pass
+
+### the page that we are looking at
+class Index(mars.view.LayoutView):
+    pass
+
+### the template for index page
+class IndexLayout(mars.template.LayoutFactory):
+    grok.template('index.pt') # required
+    grok.context(Index) # required
+
+### a manager registered for Mammoth and IModuleLayer
+class RightColumn(mars.viewlet.ViewletManager):
+
+    def render(self):
+        return u'Right column content'
+
+### a second manager registered for Mammoth and IModuleLayer
+class LeftColumn(mars.viewlet.ViewletManager):
+    """Joins output of viewlets"""
+    pass
+
+### viewlets for leftcolumn manager
+class FirstViewlet(mars.viewlet.Viewlet):
+    """A simple viewlet"""
+    grok.context(Mammoth)
+    mars.viewlet.manager(LeftColumn)
+    mars.viewlet.view(Index) # not required
+    weight = 0
+
+    def render(self):
+        return u'<div>First viewlet content</div>'
+
+### the second of which uses a template
+class SecondViewlet(mars.viewlet.Viewlet):
+    """A viewlet that has its own template"""
+    grok.context(Mammoth)
+    mars.viewlet.manager(LeftColumn)
+    weight = 1
+
+class SecondViewletTemplate(mars.template.TemplateFactory):
+    grok.template('viewlet.pt')
+    grok.context(SecondViewlet)
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/mars.viewlet/src/mars/viewlet/tests/viewlet.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/setup.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/setup.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/setup.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,97 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+    name='mars.formdemo',
+    version='0.1',
+    author='Darryl Cousins',
+    author_email='darryl.cousins at tfws.org.nz',
+    url='http://www.tfws.org.nz/mars',
+    description="""\
+Martian is a library that allows the embedding of configuration
+information in Python code. Martian can then grok the system and
+do the appropriate configuration registrations.
+
+This package uses martian to reproduce and imitiate z3c.formdemo
+as a experiment in using mars packages to configure zope apps""",
+    long_description=(
+        read('src/mars/formdemo/README.txt')
+        ),
+    packages=find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    zip_safe=False,
+    license='ZPL',
+    dependency_links = ['http://download.zope.org/distribution'],
+    extras_require = dict(
+        app = ['zope.app.appsetup',
+               'zope.app.authentication',
+               'zope.app.component',
+               'zope.app.container',
+               'zope.app.error',
+               'zope.app.form',
+               'zope.app.publisher',
+               'zope.app.publication',
+               'zope.app.security',
+               'zope.app.securitypolicy',
+               'zope.app.twisted',
+               'zope.app.wsgi',
+               'zope.contentprovider',
+               'zope.app.intid',
+                'z3c.formdemo',
+               ],
+        test = ['z3c.etestbrowser',
+                'zope.app.zcmlfiles',
+                'zope.app.testing'],
+        ),
+    install_requires = [
+        'setuptools',
+        'simplejson',
+        'grok',
+        'martian',
+        'lxml',
+        'pytz',
+        'ZODB3',
+        'z3c.csvvocabulary',
+        'z3c.form',
+        'z3c.formui',
+        'z3c.layer',
+        'z3c.pagelet',
+        'z3c.template',
+        'z3c.viewlet',
+        'z3c.zrtresource',
+        'z3c.formdemo',
+        'zc.resourcelibrary',
+        'zc.table',
+        'zope.annotation',
+                      'zope.contentprovider',
+                      'zope.app.catalog',
+                      'zope.app.folder',
+        'zope.app.container',
+        'zope.app.pagetemplate',
+        'zope.app.session',
+        'zope.component',
+        'zope.interface',
+        'zope.location',
+        'zope.pagetemplate',
+        'zope.publisher',
+        'zope.rdb',
+        'zope.schema',
+        'zope.traversing',
+        'zope.viewlet',
+        ],
+)
+        #              'zope.app.pagetemplate',
+        #              'zope.app.testing',
+        #              'zope.configuration',
+        #              'zope.dottedname',
+        #              'zope.event',
+        #              'zope.formlib',
+        #              'zope.lifecycleevent',
+        #              'zope.security',
+        #              'zope.testing',
+
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/setup.z3c.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/setup.z3c.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/setup.z3c.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,98 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation 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.
+#
+##############################################################################
+"""Setup
+
+$Id$
+"""
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup (
+    name='z3c.formdemo',
+    version='1.3.0b1',
+    author = "Stephan Richter, Roger Ineichen and the Zope Community",
+    author_email = "zope3-dev at zope.org",
+    description = "A set of demo applications for z3c.form and z3c.formui",
+    long_description=(
+        read('README.txt')
+        + '\n\n' +
+        read('CHANGES.txt')
+        ),
+    license = "ZPL 2.1",
+    keywords = "zope3 form widget",
+    classifiers = [
+        'Development Status :: 4 - Beta',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: Zope Public License',
+        'Programming Language :: Python',
+        'Natural Language :: English',
+        'Operating System :: OS Independent',
+        'Topic :: Internet :: WWW/HTTP',
+        'Framework :: Zope3'],
+    url = 'http://svn.zope.org/z3c.formdemo',
+    packages = find_packages('src'),
+    include_package_data = True,
+    package_dir = {'':'src'},
+    namespace_packages = ['z3c'],
+    extras_require = dict(
+        app = ['zope.app.appsetup',
+               'zope.app.authentication',
+               'zope.app.component',
+               'zope.app.container',
+               'zope.app.error',
+               'zope.app.form',
+               'zope.app.publisher',
+               'zope.app.publication',
+               'zope.app.security',
+               'zope.app.securitypolicy',
+               'zope.app.twisted',
+               'zope.app.wsgi',
+               'zope.contentprovider',
+               ],
+        test = ['z3c.etestbrowser',
+                'zope.app.testing'],
+        ),
+    install_requires = [
+        'setuptools',
+        'z3c.csvvocabulary',
+        'z3c.form',
+        'z3c.formui',
+        'z3c.layer',
+        'z3c.pagelet',
+        'z3c.template',
+        'z3c.viewlet',
+        'z3c.zrtresource',
+        'zc.resourcelibrary',
+        'zc.table',
+        'zope.annotation',
+        'zope.app.container',
+        'zope.app.pagetemplate',
+        'zope.app.session',
+        'zope.component',
+        'zope.interface',
+        'zope.location',
+        'zope.pagetemplate',
+        'zope.publisher',
+        'zope.rdb',
+        'zope.schema',
+        'zope.traversing',
+        'zope.viewlet',
+        ],
+    dependency_links = ['http://download.zope.org/distribution'],
+    zip_safe = False,
+    )


Property changes on: Sandbox/darrylcousins/mars.formdemo/setup.z3c.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace('mars')
+except ImportError:
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,3 @@
+=============
+Mars Formdemo
+=============


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

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/application.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/application.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/application.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,80 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:browser="http://namespaces.zope.org/browser"
+    i18n_domain="mars.formdemo">
+
+  <include package="zope.app.component" file="meta.zcml" />
+  <include package="zope.app.component.browser" file="meta.zcml" />
+  <include package="zope.app.form.browser" file="meta.zcml" />
+  <include package="zope.app.pagetemplate" file="meta.zcml" />
+  <include package="zope.app.publication" file="meta.zcml" />
+  <include package="zope.app.publisher" file="meta.zcml" />
+  <include package="zope.app.security" file="meta.zcml" />
+  <include package="zope.app.securitypolicy" file="meta.zcml" />
+  <include package="zope.rdb" file="meta.zcml" />
+  <include package="zope.viewlet" file="meta.zcml" />
+  <include package="z3c.form" file="meta.zcml" />
+  <include package="z3c.macro" file="meta.zcml" />
+  <include package="z3c.pagelet" file="meta.zcml" />
+  <include package="z3c.template" file="meta.zcml" />
+  <include package="z3c.zrtresource" file="meta.zcml" />
+  <include package="zc.resourcelibrary" file="meta.zcml" />
+
+  <include package="grok" file="meta.zcml" />
+
+  <include package="mars.layer" file="meta.zcml" />
+  <include package="mars.template" file="meta.zcml" />
+  <include package="mars.view" file="meta.zcml" />
+  <include package="mars.viewlet" file="meta.zcml" />
+  <include package="mars.resource" file="meta.zcml" />
+  <include package="mars.macro" file="meta.zcml" />
+  <include package="mars.contentprovider" file="meta.zcml" />
+  <include package="mars.adapter" file="meta.zcml" />
+
+  <browser:menu id="zmi_views" title="Views" />
+  <browser:menu id="zmi_actions" title="Actions" />
+
+  <include package="zope.app.appsetup" />
+  <include package="zope.app.component" />
+  <include package="zope.app.container" />
+  <include package="zope.app.error" />
+  <include package="zope.app.i18n" />
+  <include package="zope.app.publication" />
+  <include package="zope.app.security" />
+  <include package="zope.app.securitypolicy" />
+  <include package="zope.app.session" />
+  <include package="zope.app.twisted" />
+  <include package="zope.app.wsgi" />
+  <include package="zope.annotation" />
+  <include package="zope.component" />
+  <include package="zope.contentprovider" />
+  <include package="zope.location" />
+  <include package="zope.publisher" />
+  <include package="zope.rdb" />
+  <include package="zope.traversing" />
+  <include package="zope.traversing.browser" />
+  <include package="zope.viewlet" />
+
+  <include package="z3c.form" />
+  <include package="z3c.formui" />
+  <include package="z3c.formdemo" />
+  <include package="z3c.layer.pagelet" />
+  <include package="z3c.macro" />
+  <include package="z3c.pagelet" />
+
+  <include package="zc.resourcelibrary" />
+  <include package="zc.table" />
+
+  <include package="mars.formdemo" />
+
+  <include package="grok" />
+
+  <browser:defaultView name="index" />
+  <browser:defaultSkin name="marsformdemo" />
+
+  <securityPolicy
+  component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+  <role id="zope.Anonymous" title="Everybody" />
+  <grantAll role="zope.Anonymous" />
+</configure>

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/browser.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/browser.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/browser.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,20 @@
+from zope.app.folder.interfaces import IFolder
+
+import grok
+
+import mars.layer
+import mars.view
+import mars.template
+
+from mars.formdemo.layer import IDemoDivBrowserLayer
+
+mars.layer.layer(IDemoDivBrowserLayer)
+
+class Index(mars.view.LayoutView):
+    grok.name('index')
+    grok.context(IFolder)
+
+class IndexTemplate(mars.template.LayoutFactory):
+    grok.context(Index)
+    grok.template('index.pt') 
+    


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/browser.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/index.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/index.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/browser/index.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,15 @@
+<h1>Z3C form demos</h1>
+
+<div class="demo">
+  <h4>Div based layout</h4>
+
+  <div>
+    <a href="../++skin++marsformdemo/addHelloWorld">Hello World</a>
+  </div>
+
+  <h4>Table based layout</h4>
+  <div>
+    <a href="../++skin++marstableformdemo/addHelloWorld">Hello World</a>
+  </div>
+</div>
+

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/configure.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/configure.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/configure.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,19 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    i18n_domain="mars.formdemo">
+
+  <grok package="." xmlns="http://namespaces.zope.org/grok" />
+
+  <!-- Examples -->
+
+  <!--include package=".message" />
+  <include package=".sqlmessage" />
+  <include package=".widgets" />
+  <include package=".questionnaire" />
+  <include package=".calculator" />
+  <include package=".wizard" />
+  <include package=".spreadsheet" />
+  <include package=".addressbook" /-->
+
+</configure>
+

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/ftesting.zcml	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/ftesting.zcml	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+<include file="application.zcml" />

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/layer.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/layer.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/layer.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,11 @@
+import mars.layer
+
+class IDemoBrowserLayer(mars.layer.ILayer):
+    pass
+
+class IDemoDivBrowserLayer(mars.layer.IDivFormLayer, IDemoBrowserLayer):
+    pass
+
+class IDemoTableBrowserLayer(mars.layer.ITableFormLayer, IDemoBrowserLayer):
+    pass
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/layer.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/README.txt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/README.txt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/README.txt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,91 @@
+========================
+Hello World Message Demo
+========================
+
+The "Hello World Message" demo is intended to demonstrate the most minimal
+setup required to get add, edit and display to work.
+
+To start, we need to open a browser and go to the demo applications overview
+screen:
+
+  >>> from mars.formdemo import testing
+  >>> from z3c.etestbrowser.testing import ExtendedTestBrowser
+  >>> user = ExtendedTestBrowser()
+  >>> user.handleErrors = False
+  >>> user.addHeader('Accept-Language', 'en')
+  >>> user.open('http://localhost:8080')
+  >>> skinURL = 'http://localhost:8080/++skin++marsformdemo'
+
+Since all demos are purely public, there is no need to log in. Let's now click
+on the "Hello World" link:
+
+  >>> user.open(skinURL + '/addHelloWorld')
+
+You are now represented with the message add form.
+
+If we submit the form by clicking on add, ...
+
+  >>> user.getControl('Add').click()
+
+... the same page returns telling us we have some errors:
+
+  >>> testing.printElement(user, "//div[@class='summary']")
+  <div class="summary">There were some errors.</div>
+
+This is because we forgot to enter the "Who" field, which is required:
+
+  >>> testing.printElement(user, "//ul[@class='errors']/li")
+  <li>
+     Who: <div class="error">Required input is missing.</div>
+  </li>
+
+Let's now fill out all the required fields and try to add the message again:
+
+  >>> user.getControl('Who').value = u'Stephan'
+  >>> user.getControl('When').value = u'7/1/07'
+  >>> user.getControl('Add').click()
+
+Once submitted, the message is now added to the database and the display view
+is shown:
+
+  >>> testing.printElement(user, "//h1")
+  <h1>
+    A cool Hello World from Stephan on 7/1/07 !
+  </h1>
+
+The message's edit form can be accessed by clicking on the "Edit Message"
+link:
+
+  >>> user.getLink('Edit Message').click()
+
+When immediately pressing "Apply", a message appears telling us that no data
+has been changed:
+
+  >>> user.getControl('Apply', index=0).click()
+  >>> testing.printElement(user, "//div[@class='summary']")
+  <div class="summary">No changes were applied.</div>
+
+Let's now change the name and submit the form:
+
+  >>> user.getControl('Who').value = u'Roger'
+  >>> user.getControl('Apply', index=0).click()
+
+The page now informs us that the data has been updated:
+
+  >>> testing.printElement(user, "//div[@class='summary']")
+  <div class="summary">Data successfully updated.</div>
+
+When pressing the "Apply and View" button, the changed data is stored and the
+user is also forwarded to the view page again:
+
+  >>> user.getControl('What').getControl('best').click()
+  >>> user.getControl('Apply and View').click()
+
+Of course, the view shows the latest data:
+
+  >>> testing.printElement(user, "//h1")
+  <h1>
+    A best Hello World from Roger on 7/1/07 !
+  </h1>
+
+


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

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/display.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/display.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/display.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,8 @@
+<h1>
+  A <span tal:replace="structure view/widgets/what/render" /> Hello World
+  from <span tal:replace="structure view/widgets/who/render" />
+  on <span tal:replace="structure view/widgets/when/render" />!
+</h1>
+<a href="./edit"
+   tal:attributes="href string:${context/@@absolute_url}/edit">
+  Edit Message</a>

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/message.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/message.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/message.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,113 @@
+__docformat__ = "reStructuredText"
+import os
+import datetime
+
+import zope.interface
+import zope.schema
+from zope.schema import fieldproperty
+from zope.traversing.browser import absoluteURL
+from zope.app.folder.interfaces import IFolder
+
+from z3c.csvvocabulary import CSVVocabulary
+from z3c.form import button, field, form, widget
+from z3c.form.interfaces import IAddForm
+from z3c.formui import layout
+
+import grok
+
+import mars.view
+import mars.template
+import mars.layer
+import mars.adapter
+from mars.formdemo.layer import IDemoBrowserLayer
+
+mars.layer.layer(IDemoBrowserLayer)
+
+
+WhatVocabulary = CSVVocabulary(
+    os.path.join(os.path.dirname(__file__), 'what-values.csv'))
+
+class IHelloWorld(zope.interface.Interface):
+    """Information about a hello world message"""
+
+    who = zope.schema.TextLine(
+        title=u'Who',
+        description=u'Name of the person sending the message',
+        required=True)
+
+    when = zope.schema.Date(
+        title=u'When',
+        description=u'Date of the message sent.',
+        required=True)
+
+    what = zope.schema.Choice(
+        title=u'What',
+        description=u'What type of message it is.',
+        vocabulary=WhatVocabulary,
+        default=u'cool',
+        required=True)
+
+class DefaultDate(mars.adapter.AdapterFactory):
+    grok.name('default')
+    mars.adapter.factory(widget.ComputedWidgetAttribute(
+                        lambda adapter: datetime.date.today(),
+                        field=IHelloWorld['when'], view=IAddForm))
+
+class HelloWorld(grok.Model):
+    """Content object"""
+    zope.interface.implements(IHelloWorld)
+
+    who = fieldproperty.FieldProperty(IHelloWorld['who'])
+    when = fieldproperty.FieldProperty(IHelloWorld['when'])
+    what = fieldproperty.FieldProperty(IHelloWorld['what'])
+
+    def __init__(self, who, when, what):
+        self.who = who
+        self.when = when
+        self.what = what
+
+class Add(mars.view.FormView, layout.AddFormLayoutSupport, form.AddForm):
+    """ A sample add form."""
+    grok.name('addHelloWorld')
+    grok.context(IFolder) # override the module-level context (HelloWorld)
+
+    label = u'Hello World Message Add Form'
+    fields = field.Fields(IHelloWorld)
+
+    def create(self, data):
+        return HelloWorld(**data)
+
+    def add(self, object):
+        count = 0
+        while 'helloworld-%i' %count in self.context:
+            count += 1;
+        self._name = 'helloworld-%i' %count
+        self.context[self._name] = object
+        return object
+
+    def nextURL(self):
+        return absoluteURL(self.context[self._name], self.request)
+
+
+class Edit(mars.view.FormView, layout.FormLayoutSupport, form.EditForm):
+    grok.name('edit')
+    form.extends(form.EditForm)
+    label = u'Hello World Message Edit Form'
+    fields = field.Fields(IHelloWorld)
+
+    @button.buttonAndHandler(u'Apply and View', name='applyView')
+    def handleApplyView(self, action):
+        self.handleApply(self, action)
+        if not self.widgets.errors:
+            url = absoluteURL(self.context, self.request)
+            self.request.response.redirect(url)
+
+
+class Display(mars.view.FormView, layout.FormLayoutSupport, form.DisplayForm):
+    grok.name('index')
+    fields = field.Fields(IHelloWorld)
+
+class DisplayTemplate(mars.template.LayoutFactory):
+    grok.context(Display)
+    grok.template('display.pt')
+


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/message.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/what-values.csv
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/what-values.csv	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/message/what-values.csv	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,4 @@
+"cool";"cool"
+"sunny";"sunny"
+"silent";"silent"
+"best";"best"

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/__init__.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/__init__.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/__init__.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1 @@
+#


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/demo.css
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/demo.css	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/demo.css	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,91 @@
+/* zrt-replace: "./img" tal"string:${context/++resource++img}" */
+
+body {
+    font: 11px Verdana, Helvetica, Arial, sans-serif;
+    margin: 0px;
+    padding: 0px;
+}
+
+/* [ html ]---------------------------------------------------------------- */
+
+form {
+    margin: 0px;
+    padding: 0px;
+}
+
+img {
+    border: 0;
+}
+
+a {
+    color: #D91813;
+    text-decoration: none;
+}
+
+a:link {
+    color: #D91813;
+    text-decoration: none;
+}
+
+a:visited {
+    color: #A68E8E;
+    text-decoration: none;
+}
+
+a:hover {
+    color: #8C100D;
+}
+
+fieldset {
+    padding: 5px;
+}
+
+
+h1, h2, h3, h4, h5, h6 {
+    color: Black;
+    clear: left;
+    font: 100% bold Verdana, Helvetica, Arial, sans-serif;
+    margin: 0;
+    padding-top: 0.5em;
+}
+
+h1 {
+    font-size: 160%;
+}
+
+h2 {
+    font-size: 140%;
+}
+
+h3 {
+    height: 20px;
+    font-size: 120%;
+    background-color: #DDDCD0;
+    padding: 2px 0px 0px 5px;
+}
+
+h4 {
+    color: #777777;
+    font-size: 100%;
+    font-weight: bold;
+}
+
+h5 {
+    font-size: 90%;
+}
+
+h6 {
+    font-size: 80%;
+}
+
+
+/* ---[ demo layout tags ]--------------------------------------------------- */
+
+#content {
+    padding: 20px;
+}
+
+div.demo {
+    padding-bottom: 2px;
+}
+

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/images/loading.gif
===================================================================
(Binary files differ)


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/images/loading.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/images/loading.png
===================================================================
(Binary files differ)


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/images/loading.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/skin.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/skin.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/skin.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,59 @@
+import zope.interface
+from zope.viewlet.viewlet import CSSViewlet
+from zope.publisher.interfaces.browser import IBrowserPage
+
+import z3c.formui
+
+import grok
+
+import mars.layer
+import mars.template
+import mars.viewlet
+import mars.resource
+
+from mars.formdemo.layer import (IDemoBrowserLayer,
+                                 IDemoDivBrowserLayer,
+                                 IDemoTableBrowserLayer)
+
+class MarsFormDemo(mars.layer.Skin):
+    """The ``marsformdemo`` browser skin."""
+    mars.layer.layer(IDemoDivBrowserLayer)
+
+class MarsTableFormDemo(mars.layer.Skin):
+    """The ``marstableformdemo`` browser skin."""
+    mars.layer.layer(IDemoTableBrowserLayer)
+
+mars.layer.layer(IDemoBrowserLayer)
+
+# main template for pages (note the context!)
+class Template(mars.template.LayoutFactory):
+    grok.context(IBrowserPage)
+    grok.template('template.pt')
+
+# css viewletmanager
+class CSS(mars.viewlet.ViewletManager):
+    zope.interface.implements(z3c.formui.interfaces.ICSS)
+    grok.name('ICSS')
+    grok.context(zope.interface.Interface)
+
+# javascript viewletmanager
+class JavaScript(mars.viewlet.ViewletManager):
+    grok.name('IJavaScript')
+    grok.context(zope.interface.Interface)
+
+# css viewlet
+DemoCSSViewlet = CSSViewlet('demo.css')
+class FormDemoCSSViewlet(mars.viewlet.SimpleViewlet, DemoCSSViewlet):
+    grok.name('demo.css')
+    grok.context(zope.interface.Interface)
+    mars.viewlet.manager(CSS)
+
+
+# resources (++resource++demo.css)
+class DemoStyle(mars.resource.ResourceFactory):
+    grok.name('demo.css')
+    mars.resource.file('demo.css')
+
+# image resource directory (++resource++images)
+class Images(mars.resource.ResourceDirectoryFactory):
+    mars.resource.directory('images')


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/skin.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/template.pt
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/template.pt	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/skin/template.pt	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
+      i18n:domain="z3c.formdemo">
+<head>
+<title>Z3C Demo</title>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<meta http-equiv="cache-control" content="no-cache" />
+<meta http-equiv="pragma" content="no-cache" />
+<script type="text/javascript"
+    tal:define="contexturl context/@@absolute_url; 
+                viewurl request/URL"
+    tal:content="string:
+	var contextURL = '${contexturl}';
+	var viewURL = '${viewurl}';"> 
+</script>
+<script tal:replace="structure provider:IJavaScript"> </script>
+<style tal:replace="structure provider:ICSS"> 
+</style>
+</head>
+<body>
+<div id="content">
+  <tal:block replace="structure provider:pagelet" />
+</div>
+</body>
+</html>
+

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/testing.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/testing.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/testing.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,24 @@
+__docformat__ = "reStructuredText"
+import tempfile
+import lxml.etree
+import os
+from zope.rdb import gadflyda
+from zope.app.testing.functional import ZCMLLayer
+
+def setUp(test):
+    gadfly_dir = tempfile.mkdtemp()
+    os.mkdir(os.path.join(gadfly_dir, 'msg'))
+    gadflyda.setGadflyRoot(gadfly_dir)
+
+def printElement(browser, xpath, multiple=False, serialize=True):
+    result = [serialize and lxml.etree.tounicode(elem) or elem
+              for elem in browser.etree.xpath(xpath)]
+    if not multiple:
+        print result[0]
+        return
+    for elem in result:
+        print elem
+
+FormDemoLayer = ZCMLLayer(
+    os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
+    __name__, 'MarsFormDemoLayer', allow_teardown=True)


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/testing.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/tests.py
===================================================================
--- Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/tests.py	                        (rev 0)
+++ Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/tests.py	2007-07-06 21:09:40 UTC (rev 77533)
@@ -0,0 +1,24 @@
+__docformat__ = "reStructuredText"
+import os
+import unittest
+from zope.app.testing import functional
+from mars.formdemo import testing
+
+def getRootFolder():
+    return functional.FunctionalTestSetup().getRootFolder()
+
+def test_suite():
+    suites = []
+    for docpath in (('message', 'README.txt'),
+                    ):
+        suite = functional.FunctionalDocFileSuite(
+            os.path.join(*docpath),
+            setUp=testing.setUp,
+            globs={'getRootFolder': getRootFolder})
+        suite.layer = testing.FormDemoLayer
+        suites.append(suite)
+    return unittest.TestSuite(suites)
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')


Property changes on: Sandbox/darrylcousins/mars.formdemo/src/mars/formdemo/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Checkins mailing list