[Checkins] SVN: grok/branches/darrylcousins-branch/ Using mars
namespace and rethinking packages. layer and template added,
layers tests pass, still developing template tests.
Darryl Cousins
darryl at darrylcousins.net.nz
Wed Jul 4 00:28:17 EDT 2007
Log message for revision 77385:
Using mars namespace and rethinking packages. layer and template added, layers tests pass, still developing template tests.
Changed:
U grok/branches/darrylcousins-branch/buildout.cfg
A grok/branches/darrylcousins-branch/mars.layer/
A grok/branches/darrylcousins-branch/mars.layer/setup.py
A grok/branches/darrylcousins-branch/mars.layer/src/
A grok/branches/darrylcousins-branch/mars.layer/src/mars/
A grok/branches/darrylcousins-branch/mars.layer/src/mars/__init__.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/README.txt
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/__init__.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/components.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.txt
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/interfaces.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.zcml
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/__init__.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/configure.zcml
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal-ftesting.zcml
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet-ftesting.zcml
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet.py
A grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/test_all.py
A grok/branches/darrylcousins-branch/mars.template/
A grok/branches/darrylcousins-branch/mars.template/setup.py
A grok/branches/darrylcousins-branch/mars.template/src/
A grok/branches/darrylcousins-branch/mars.template/src/mars/
A grok/branches/darrylcousins-branch/mars.template/src/mars/__init__.py
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/README.txt
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/__init__.py
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/components.py
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.py
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.txt
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/interfaces.py
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.py
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.zcml
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/__init__.py
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/configure.zcml
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/ftesting.zcml
A grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/test_all.py
D grok/branches/darrylcousins-branch/megrok.layer/
D grok/branches/darrylcousins-branch/megrok.template/
D grok/branches/darrylcousins-branch/megrok.view/
D grok/branches/darrylcousins-branch/megrok.viewlet/
-=-
Modified: grok/branches/darrylcousins-branch/buildout.cfg
===================================================================
--- grok/branches/darrylcousins-branch/buildout.cfg 2007-07-03 23:21:31 UTC (rev 77384)
+++ grok/branches/darrylcousins-branch/buildout.cfg 2007-07-04 04:28:16 UTC (rev 77385)
@@ -1,5 +1,5 @@
[buildout]
-develop = . megrok.layer megrok.viewlet megrok.view megrok.template
+develop = . mars.layer mars.template
parts = app data instance test
find-links = http://download.zope.org/distribution/
@@ -10,10 +10,8 @@
[app]
eggs = grok
martian
- megrok.layer
- megrok.template
- megrok.viewlet
- megrok.view
+ mars.layer
+ mars.template
recipe = zc.zope3recipes:app
site.zcml = <include package="zope.security" file="meta.zcml" />
<include package="zope.i18n" file="meta.zcml" />
@@ -21,9 +19,9 @@
<include package="zope.app.zcmlfiles" file="meta.zcml" />
<include package="zope.viewlet" file="meta.zcml" />
<include package="grok" file="meta.zcml" />
- <include package="megrok.view" file="meta.zcml" />
- <include package="megrok.layer" file="meta.zcml" />
- <include package="megrok.viewlet" file="meta.zcml" />
+ <include package="mars.view" file="meta.zcml" />
+ <include package="mars.layer" file="meta.zcml" />
+ <include package="mars.viewlet" file="meta.zcml" />
<include package="zope.annotation" />
<include package="zope.copypastemove" />
@@ -89,9 +87,7 @@
recipe = zc.recipe.testrunner
eggs = grok
martian
- megrok.layer
- megrok.template
- megrok.viewlet
- megrok.view
+ mars.layer
+ mars.template
defaults = ['--tests-pattern', '^f?tests$', '-v']
Added: grok/branches/darrylcousins-branch/mars.layer/setup.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/setup.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/setup.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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.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',
+ ],
+)
+
+
Property changes on: grok/branches/darrylcousins-branch/mars.layer/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/__init__.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/__init__.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/__init__.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.layer/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/README.txt
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/README.txt (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/README.txt 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,27 @@
+==========
+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)
+
Property changes on: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/README.txt
___________________________________________________________________
Name: svn:keywords
+ Date Author
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/__init__.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/__init__.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/__init__.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,3 @@
+from directive import layer
+from components import Skin, IMinimalLayer, IPageletLayer
+
Property changes on: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/components.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/components.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/components.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,18 @@
+from zope.publisher.interfaces.browser import IBrowserRequest
+import zope.interface
+from z3c.layer.pagelet import IPageletBrowserLayer
+from z3c.layer.minimal import IMinimalBrowserLayer
+
+class ILayer(zope.interface.Interface):
+ pass
+
+class IMinimalLayer(ILayer, IMinimalBrowserLayer):
+ pass
+
+class IPageletLayer(ILayer, IPageletBrowserLayer):
+ pass
+
+class Skin(object):
+ pass
+
+
Property changes on: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/components.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,5 @@
+from grok.directive import (InterfaceOrClassDirective,
+ ClassOrModuleDirectiveContext)
+
+layer = InterfaceOrClassDirective('mars.layer.layer',
+ ClassOrModuleDirectiveContext())
Property changes on: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.txt
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.txt (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.txt 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/directive.txt
___________________________________________________________________
Name: svn:keywords
+ Date Author
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/interfaces.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/interfaces.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/interfaces.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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())
+ zope.component.interface.provideInterface(name, layer, IBrowserSkinType)
+
+ return True
Property changes on: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.zcml
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.zcml (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/meta.zcml 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/__init__.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/__init__.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/__init__.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1 @@
+#
Property changes on: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/configure.zcml
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/configure.zcml (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/configure.zcml 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,6 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope">
+
+
+</configure>
+
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal-ftesting.zcml
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal-ftesting.zcml (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal-ftesting.zcml 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,42 @@
+"""
+
+ >>> 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
+
+class MySkin(mars.layer.Skin):
+ mars.layer.layer(IMyLayer)
+
Property changes on: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/minimal.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet-ftesting.zcml
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet-ftesting.zcml (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet-ftesting.zcml 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/pagelet.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/test_all.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/test_all.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/test_all.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,26 @@
+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():
+ dottedname = 'mars.layer.tests.%s'
+ suite = unittest.TestSuite()
+ test = FunctionalDocTestSuite(dottedname % 'minimal')
+ 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: grok/branches/darrylcousins-branch/mars.layer/src/mars/layer/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/setup.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/setup.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/setup.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.template/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/__init__.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/__init__.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/__init__.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.template/src/mars/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/README.txt
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/README.txt (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/README.txt 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,14 @@
+=============
+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.
+
+
Property changes on: grok/branches/darrylcousins-branch/mars.template/src/mars/template/README.txt
___________________________________________________________________
Name: svn:keywords
+ Date Author
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/__init__.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/__init__.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/__init__.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,2 @@
+from directive import macro, content_type
+from components import TemplateFactory, LayoutFactory
Property changes on: grok/branches/darrylcousins-branch/mars.template/src/mars/template/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/components.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/components.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/components.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,8 @@
+class TemplateFactory(object):
+ pass
+
+
+class LayoutFactory(object):
+ pass
+
+
Property changes on: grok/branches/darrylcousins-branch/mars.template/src/mars/template/components.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.txt
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.txt (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.txt 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,52 @@
+========================
+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.
+ 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.
+ 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: grok/branches/darrylcousins-branch/mars.template/src/mars/template/directive.txt
___________________________________________________________________
Name: svn:keywords
+ Date Author
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/interfaces.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/interfaces.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/interfaces.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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: grok/branches/darrylcousins-branch/mars.template/src/mars/template/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,87 @@
+import os
+
+import zope.component
+import zope.interface
+from zope.publisher.interfaces.browser import IBrowserRequest
+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
+
+ 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()
+
+ template_name = util.class_annotation(factory, 'grok.template',
+ factory_name)
+ template = templates.get(template_name)
+ if not template:
+ raise GrokError("No template found for %r. Please define a template"
+ "to use."
+ % (factory),
+ factory)
+ if factory_name != template_name:
+ # grok.template is being used
+ if templates.get(factory_name):
+ raise GrokError("Multiple possible templates for template %r. It "
+ "uses grok.template('%s'), but there is also "
+ "a template called '%s'."
+ % (factory, template_name, 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 IBrowserRequest
+ view_name = util.class_annotation(factory, 'grok.name', '')
+
+
+ filename = template.__grok_location__
+ if not os.path.exists(filename):
+ raise GrokError("Inline templates are not supported for %s."
+ " Please drop a tempate named %s in %s_templates."
+ % (factory.__name__, factory_name, factory.module_info.name),
+ factory)
+ factory = TemplateFactory(filename, contentType, macro)
+ templates.markAssociated(template_name)
+ zope.interface.directlyProvides(factory, provides)
+ print '\nname:', view_name,'context:', view_context,'factory:', factory, '\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
+
+ @property
+ def provides(self):
+ return IPageTemplate
+
+class LayoutFactoryGrokker(TemplateFactoryGrokkerBase):
+ component_class = mars.template.LayoutFactory
+
+ @property
+ def provides(self):
+ return ILayoutTemplate
+
+
Property changes on: grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.zcml
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.zcml (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/meta.zcml 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1 @@
+<grok package=".meta" xmlns="http://namespaces.zope.org/grok" />
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/__init__.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/__init__.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/__init__.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1 @@
+#
Property changes on: grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/configure.zcml
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/configure.zcml (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/configure.zcml 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,7 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope">
+
+ <include file="ftesting.zcml" />
+
+</configure>
+
Added: grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/ftesting.zcml
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/ftesting.zcml (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/ftesting.zcml 2007-07-04 04:28:16 UTC (rev 77385)
@@ -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="zope.app.pagetemplate" 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: grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/test_all.py
===================================================================
--- grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/test_all.py (rev 0)
+++ grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/test_all.py 2007-07-04 04:28:16 UTC (rev 77385)
@@ -0,0 +1,39 @@
+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')
+
+def suiteFromPackage(name):
+ files = resource_listdir(__name__, name)
+ suite = unittest.TestSuite()
+ for filename in files:
+ if not filename.endswith('.py'):
+ continue
+ if filename == '__init__.py':
+ continue
+ if filename == 'test_all.py':
+ continue
+
+ dottedname = 'mars.template.tests.%s' % (filename[:-3])
+ test = FunctionalDocTestSuite(dottedname)
+ test.layer = TestLayer
+
+ suite.addTest(test)
+ return suite
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(suiteFromPackage('.'))
+ return suite
+
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
+
+
Property changes on: grok/branches/darrylcousins-branch/mars.template/src/mars/template/tests/test_all.py
___________________________________________________________________
Name: svn:keywords
+ Id
More information about the Checkins
mailing list