[Checkins] SVN: Sandbox/darrylcousins/mars.template/ Updating

Darryl Cousins darryl at darrylcousins.net.nz
Sun Feb 3 22:20:31 EST 2008


Log message for revision 83481:
  Updating

Changed:
  U   Sandbox/darrylcousins/mars.template/buildout.cfg
  U   Sandbox/darrylcousins/mars.template/src/mars/template/ftests/directive.py
  U   Sandbox/darrylcousins/mars.template/src/mars/template/ftests/ftesting.zcml
  U   Sandbox/darrylcousins/mars.template/src/mars/template/ftests/layout.py
  U   Sandbox/darrylcousins/mars.template/src/mars/template/ftests/test_functional.py
  U   Sandbox/darrylcousins/mars.template/src/mars/template/meta.py
  U   Sandbox/darrylcousins/mars.template/src/mars/template/template.txt
  U   Sandbox/darrylcousins/mars.template/src/mars/template/tests.py

-=-
Modified: Sandbox/darrylcousins/mars.template/buildout.cfg
===================================================================
--- Sandbox/darrylcousins/mars.template/buildout.cfg	2008-02-04 03:20:03 UTC (rev 83480)
+++ Sandbox/darrylcousins/mars.template/buildout.cfg	2008-02-04 03:20:30 UTC (rev 83481)
@@ -1,15 +1,11 @@
 [buildout]
 develop = .
 parts = test
-eggs-directory = /opt/buildout/mars/eggs
-develop-eggs-directory = /opt/buildout/mars/develop-eggs
-extends = http://grok.zope.org/releaseinfo/grok-0.10.2.cfg
+extends = http://grok.zope.org/releaseinfo/grok-0.11.1.cfg
 versions = versions
-executable = /opt/sandbox/mars/bin/python2.4
 
 [versions]
-zope.securitypolicy = 3.4.0
-zope.app.securitypolicy = 3.4.3
+martian = 0.9.2
 
 [test]
 recipe = zc.recipe.testrunner
@@ -17,7 +13,3 @@
 defaults = ['--tests-pattern', '^f?tests$',
 	'-v'
 	]
-
-[zope3]
-location = .
-

Modified: Sandbox/darrylcousins/mars.template/src/mars/template/ftests/directive.py
===================================================================
--- Sandbox/darrylcousins/mars.template/src/mars/template/ftests/directive.py	2008-02-04 03:20:03 UTC (rev 83480)
+++ Sandbox/darrylcousins/mars.template/src/mars/template/ftests/directive.py	2008-02-04 03:20:30 UTC (rev 83481)
@@ -39,8 +39,8 @@
 class IMyLayer(mars.layer.IMinimalLayer):
     pass
 
-class MySkin(mars.layer.Skin):
-    mars.layer.layer(IMyLayer)
+class MySkin(grok.Skin):
+    grok.layer(IMyLayer)
 
 class IMyPageTemplate(zope.interface.Interface):
     pass
@@ -50,7 +50,7 @@
 
 class View(mars.view.LayoutView):
     """Here use LayoutView which uses layers"""
-    mars.layer.layer(IMyLayer)
+    grok.layer(IMyLayer)
     mars.view.layout('complex') # forces named layout template lookup
     _layout_interface = IMyPageTemplate # if template provides specific interface
 
@@ -64,6 +64,6 @@
     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.
+    grok.layer(IMyLayer) # registered on this layer.
     
 

Modified: Sandbox/darrylcousins/mars.template/src/mars/template/ftests/ftesting.zcml
===================================================================
--- Sandbox/darrylcousins/mars.template/src/mars/template/ftests/ftesting.zcml	2008-02-04 03:20:03 UTC (rev 83480)
+++ Sandbox/darrylcousins/mars.template/src/mars/template/ftests/ftesting.zcml	2008-02-04 03:20:30 UTC (rev 83481)
@@ -1,13 +1,11 @@
 <configure xmlns="http://namespaces.zope.org/zope"
-           xmlns:meta="http://namespaces.zope.org/meta"
-           xmlns:browser="http://namespaces.zope.org/browser"
+           xmlns:grok="http://namespaces.zope.org/grok"
            i18n_domain="zope"
            package="mars.template.ftests">
 
   <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" />
 
@@ -60,6 +58,7 @@
 
 
   <include package="grok" />
+  <grok:grok package="mars.template.ftests" />
 
 </configure>
 

Modified: Sandbox/darrylcousins/mars.template/src/mars/template/ftests/layout.py
===================================================================
--- Sandbox/darrylcousins/mars.template/src/mars/template/ftests/layout.py	2008-02-04 03:20:03 UTC (rev 83480)
+++ Sandbox/darrylcousins/mars.template/src/mars/template/ftests/layout.py	2008-02-04 03:20:30 UTC (rev 83481)
@@ -3,7 +3,6 @@
 
   >>> import grok
   >>> from mars.template.ftests.layout import Mammoth
-  >>> grok.grok('mars.template.ftests.layout')
 
   >>> mammoth = getRootFolder()["mammoth"] = Mammoth()
 

Modified: Sandbox/darrylcousins/mars.template/src/mars/template/ftests/test_functional.py
===================================================================
--- Sandbox/darrylcousins/mars.template/src/mars/template/ftests/test_functional.py	2008-02-04 03:20:03 UTC (rev 83480)
+++ Sandbox/darrylcousins/mars.template/src/mars/template/ftests/test_functional.py	2008-02-04 03:20:30 UTC (rev 83481)
@@ -1,19 +1,24 @@
+import os
 import unittest
+
 from zope.testing import doctest
-
-from zope.app.testing.functional import FunctionalTestSetup, getRootFolder
 from zope.app.testing import functional
-functional.defineLayer('TestLayer', 'ftesting.zcml')
-functional.defineLayer('TestMinimalLayer', 'minimal-ftesting.zcml')
 
+ftesting_zcml = os.path.join(os.path.dirname(__file__), 'ftesting.zcml')
+TestLayer = functional.ZCMLLayer(
+                       ftesting_zcml, __name__, 'TestLayer')
+min_ftesting_zcml = os.path.join(os.path.dirname(__file__), 'minimal_ftesting.zcml')
+TestMinimalLayer = functional.ZCMLLayer(
+                       min_ftesting_zcml, __name__, 'TestMinimalLayer')
+
 optionflags = doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS
-globs = dict(getRootFolder=getRootFolder)
+globs = dict(getRootFolder=functional.getRootFolder)
 
 def setUp(test):
-    FunctionalTestSetup().setUp()
+    functional.FunctionalTestSetup().setUp()
 
 def tearDown(test):
-    FunctionalTestSetup().tearDown()
+    functional.FunctionalTestSetup().tearDown()
 
 def test_suite():
     suite = unittest.TestSuite()

Modified: Sandbox/darrylcousins/mars.template/src/mars/template/meta.py
===================================================================
--- Sandbox/darrylcousins/mars.template/src/mars/template/meta.py	2008-02-04 03:20:03 UTC (rev 83480)
+++ Sandbox/darrylcousins/mars.template/src/mars/template/meta.py	2008-02-04 03:20:30 UTC (rev 83481)
@@ -16,7 +16,7 @@
 from martian.error import GrokError
 
 import grok
-from grok.util import check_adapts
+from grok.util import determine_class_directive
 
 import mars.template
 
@@ -25,8 +25,8 @@
     component_class = None
     provides = None
 
-    def grok(self, name, factory, context, module_info, templates):
-        view_context = util.determine_class_context(factory, context)
+    def grok(self, name, factory, module_info, config, *kws):
+     
         factory.module_info = module_info
         factory_name = factory.__name__.lower()
 
@@ -45,23 +45,30 @@
                             % (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', '')
+        view_layer = determine_class_directive('grok.layer',
+                                               factory, module_info,
+                                               default=IDefaultBrowserLayer)
+        view_name = util.class_annotation(factory, 'grok.name', u'')
+        view_context = determine_class_directive('grok.context',
+                                               factory, module_info,
+                                               default=zope.interface.Interface)
 
         factory = TemplateFactory(filepath, contentType, macro)
+
+
+        provides = util.class_annotation(factory, 'grok.provides', self.provides)
         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)
+
+        adapts = (view_context, view_layer)
+
+        config.action( 
+            discriminator=('adapter', adapts, provides, view_name),
+            callable=zope.component.provideAdapter,
+            args=(factory, adapts, provides, view_name),
+            )
         return True
 
 

Modified: Sandbox/darrylcousins/mars.template/src/mars/template/template.txt
===================================================================
--- Sandbox/darrylcousins/mars.template/src/mars/template/template.txt	2008-02-04 03:20:03 UTC (rev 83480)
+++ Sandbox/darrylcousins/mars.template/src/mars/template/template.txt	2008-02-04 03:20:30 UTC (rev 83481)
@@ -46,6 +46,7 @@
 
   >>> class TemplateView(grok.View):
   ...     grok.name('view.html')
+  ...     grok.context(zope.interface.Interface)
   ...     zope.interface.implements(ITemplateView)
   ...     def render(self):
   ...         template = zope.component.getMultiAdapter(
@@ -56,9 +57,9 @@
 module is ``grokked`` on start up.
 
   >>> from grok.meta import ViewGrokker
-  >>> ViewGrokker().grok('', TemplateView, zope.interface.Interface,
-  ...                               module_info, {})
+  >>> ViewGrokker().grok('', TemplateView, module_info, config)
   True
+  >>> config.execute_actions()
 
 Templates
 ---------
@@ -96,8 +97,9 @@
 Again we must manually ``grok`` the class.
 
   >>> from mars.template.meta import TemplateFactoryGrokker
-  >>> TemplateFactoryGrokker().grok('', Template, None, module_info, None)
+  >>> TemplateFactoryGrokker().grok('', Template, module_info, config)
   True
+  >>> config.execute_actions()
 
 View the view
 -------------
@@ -144,8 +146,9 @@
   ...     grok.context(ILayoutView)
 
   >>> from mars.template.meta import LayoutFactoryGrokker
-  >>> LayoutFactoryGrokker().grok('', LayoutTemplate, None, module_info, None)
+  >>> LayoutFactoryGrokker().grok('', LayoutTemplate,  module_info, config)
   True
+  >>> config.execute_actions()
 
   >>> view = LayoutView(content, request)
   >>> print view()

Modified: Sandbox/darrylcousins/mars.template/src/mars/template/tests.py
===================================================================
--- Sandbox/darrylcousins/mars.template/src/mars/template/tests.py	2008-02-04 03:20:03 UTC (rev 83480)
+++ Sandbox/darrylcousins/mars.template/src/mars/template/tests.py	2008-02-04 03:20:30 UTC (rev 83481)
@@ -2,6 +2,7 @@
 from zope.testing import doctest
 
 import zope.interface
+from zope.configuration.config import ConfigurationMachine
 
 from martian.interfaces import IModuleInfo
 
@@ -13,22 +14,16 @@
     def getAnnotation(self, name, default):
         return default
 
-globs = dict(module_info=ModuleInfo())
+globs = dict(module_info=ModuleInfo(),
+             config=ConfigurationMachine())
 
 optionflags = doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS
 
-def setUp(test):
-    pass
-
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTests([doctest.DocFileSuite('./template.txt',
-                             setUp=setUp, globs=globs,
+                             globs=globs,
                              optionflags=optionflags),
                    ])
 
     return suite
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
-



More information about the Checkins mailing list