[Checkins] SVN: grok/trunk/ Update to new Martian.
Martijn Faassen
faassen at infrae.com
Wed Jun 11 13:24:37 EDT 2008
Log message for revision 87316:
Update to new Martian.
Changed:
U grok/trunk/CHANGES.txt
U grok/trunk/setup.py
U grok/trunk/src/grok/admin/docgrok.py
U grok/trunk/src/grok/meta.py
U grok/trunk/src/grok/tests/grokker/continue_scanning.py
U grok/trunk/src/grok/tests/grokker/onlyonce_fixture/_meta.py
U grok/trunk/src/grok/tests/grokker/onlyonce_fixture/component.py
U grok/trunk/src/grok/tests/grokker/priority.py
U grok/trunk/versions.cfg
-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/CHANGES.txt 2008-06-11 17:24:37 UTC (rev 87316)
@@ -18,7 +18,8 @@
directives themselves now.
* Refactored class grokkers to make use of Martian's new declarative
- way for retrieving directive data from classes.
+ way for retrieving directive data from classes, and Martian's new
+ declarative way to write grokkers.
Feature changes
---------------
Modified: grok/trunk/setup.py
===================================================================
--- grok/trunk/setup.py 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/setup.py 2008-06-11 17:24:37 UTC (rev 87316)
@@ -35,8 +35,8 @@
include_package_data = True,
zip_safe=False,
install_requires=['setuptools',
- 'martian >= 0.9.7',
- 'grokcore.component >= 1.3',
+ 'martian >= 0.10',
+ 'grokcore.component >= 1.4',
'simplejson',
'pytz',
'ZODB3',
Modified: grok/trunk/src/grok/admin/docgrok.py
===================================================================
--- grok/trunk/src/grok/admin/docgrok.py 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/src/grok/admin/docgrok.py 2008-06-11 17:24:37 UTC (rev 87316)
@@ -45,6 +45,7 @@
import grok.interfaces
from grok.interfaces import IApplication
+import martian
from martian.scan import is_package, ModuleInfo
from martian import ClassGrokker, ModuleGrokker
from grok.admin.objectinfo import ZopeObjectInfo
@@ -287,7 +288,7 @@
That's it.
"""
- component_class = DocGrokHandler
+ martian.component(DocGrokHandler)
def grok(self, name, obj, **kw):
if not issubclass(obj, DocGrokHandler):
Modified: grok/trunk/src/grok/meta.py
===================================================================
--- grok/trunk/src/grok/meta.py 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/src/grok/meta.py 2008-06-11 17:24:37 UTC (rev 87316)
@@ -75,7 +75,7 @@
class ViewletManagerContextGrokker(martian.GlobalGrokker):
- priority = 1001
+ martian.priority(1001)
def grok(self, name, module, module_info, config, **kw):
viewletmanager = determine_module_component(module_info,
@@ -86,11 +86,9 @@
class XMLRPCGrokker(martian.MethodGrokker):
- component_class = grok.XMLRPC
- directives = [
- grok.context.bind(),
- grok.require.bind(name='permission'),
- ]
+ martian.component(grok.XMLRPC)
+ martian.directive(grok.context)
+ martian.directive(grok.require, name='permission')
def execute(self, factory, method, config, context, permission, **kw):
name = method.__name__
@@ -117,12 +115,10 @@
class RESTGrokker(martian.MethodGrokker):
- component_class = grok.REST
- directives = [
- grok.context.bind(),
- grok.layer.bind(default=grok.IRESTLayer),
- grok.require.bind(name='permission'),
- ]
+ martian.component(grok.REST)
+ martian.directive(grok.context)
+ martian.directive(grok.layer, default=grok.IRESTLayer)
+ martian.directive(grok.require, name='permission')
def execute(self, factory, method, config, permission, context, layer, **kw):
name = method.__name__
@@ -147,13 +143,11 @@
class ViewGrokker(martian.ClassGrokker):
- component_class = grok.View
- directives = [
- grok.context.bind(),
- grok.layer.bind(default=IDefaultBrowserLayer),
- grok.name.bind(get_default=default_view_name),
- grok.require.bind(name='permission'),
- ]
+ martian.component(grok.View)
+ martian.directive(grok.context)
+ martian.directive(grok.layer, default=IDefaultBrowserLayer)
+ martian.directive(grok.name, get_default=default_view_name)
+ martian.directive(grok.require, name='permission')
def grok(self, name, factory, module_info, **kw):
# Need to store the module info object on the view class so that it
@@ -222,11 +216,9 @@
class JSONGrokker(martian.MethodGrokker):
- component_class = grok.JSON
- directives = [
- grok.context.bind(),
- grok.require.bind(name='permission'),
- ]
+ martian.component(grok.JSON)
+ martian.directive(grok.context)
+ martian.directive(grok.require, name='permission')
# TODO: this grokker doesn't support layers yet
@@ -254,10 +246,8 @@
class TraverserGrokker(martian.ClassGrokker):
- component_class = grok.Traverser
- directives = [
- grok.context.bind()
- ]
+ martian.component(grok.Traverser)
+ martian.directive(grok.context)
def execute(self, factory, config, context, **kw):
adapts = (context, IHTTPRequest)
@@ -272,7 +262,7 @@
class TemplateGrokker(martian.GlobalGrokker):
# this needs to happen before any other grokkers execute that use
# the template registry
- priority = 1001
+ martian.priority(1001)
def grok(self, name, module, module_info, config, **kw):
module.__grok_templates__ = templatereg.TemplateRegistry()
@@ -280,12 +270,11 @@
class ModulePageTemplateGrokker(martian.InstanceGrokker):
+ martian.component(grok.components.BaseTemplate)
# this needs to happen before any other grokkers execute that actually
# use the templates
- priority = 1000
-
- component_class = grok.components.BaseTemplate
-
+ martian.priority(1000)
+
def grok(self, name, instance, module_info, config, **kw):
templates = module_info.getAnnotation('grok.templates', None)
if templates is None:
@@ -307,7 +296,7 @@
# do this early on, but after ModulePageTemplateGrokker, as
# findFilesystem depends on module-level templates to be
# already grokked for error reporting
- priority = 999
+ martian.priority(999)
def grok(self, name, module, module_info, config, **kw):
templates = module_info.getAnnotation('grok.templates', None)
@@ -322,7 +311,7 @@
class UnassociatedTemplatesGrokker(martian.GlobalGrokker):
- priority = -1001
+ martian.priority(-1001)
def grok(self, name, module, module_info, config, **kw):
templates = module_info.getAnnotation('grok.templates', None)
@@ -374,11 +363,9 @@
class SiteGrokker(martian.ClassGrokker):
- component_class = grok.Site
- priority = 500
- directives = [
- grok.local_utility.bind(name='infos'),
- ]
+ martian.component(grok.Site)
+ martian.priority(500)
+ martian.directive(grok.local_utility, name='infos')
def execute(self, factory, config, infos, **kw):
if not infos:
@@ -461,13 +448,11 @@
class PermissionGrokker(martian.ClassGrokker):
- component_class = grok.Permission
- priority = 1500
- directives = [
- grok.name.bind(),
- grok.title.bind(get_default=default_fallback_to_name),
- grok.description.bind(),
- ]
+ martian.component(grok.Permission)
+ martian.priority(1500)
+ martian.directive(grok.name)
+ martian.directive(grok.title, get_default=default_fallback_to_name)
+ martian.directive(grok.description)
def execute(self, factory, config, name, title, description, **kw):
if not name:
@@ -489,14 +474,12 @@
class RoleGrokker(martian.ClassGrokker):
- component_class = grok.Role
- priority = PermissionGrokker.priority - 1
- directives = [
- grok.name.bind(),
- grok.title.bind(get_default=default_fallback_to_name),
- grok.description.bind(),
- grok.permissions.bind(),
- ]
+ martian.component(grok.Role)
+ martian.priority(martian.priority.bind().get(PermissionGrokker()) - 1)
+ martian.directive(grok.name)
+ martian.directive(grok.title, get_default=default_fallback_to_name)
+ martian.directive(grok.description)
+ martian.directive(grok.permissions)
def execute(self, factory, config, name, title, description,
permissions, **kw):
@@ -524,12 +507,10 @@
class AnnotationGrokker(martian.ClassGrokker):
- component_class = grok.Annotation
- directives = [
- grok.context.bind(name='adapter_context'),
- grok.provides.bind(get_default=default_annotation_provides),
- grok.name.bind(get_default=default_annotation_name),
- ]
+ martian.component(grok.Annotation)
+ martian.directive(grok.context, name='adapter_context')
+ martian.directive(grok.provides, get_default=default_annotation_provides)
+ martian.directive(grok.name, get_default=default_annotation_name)
def execute(self, factory, config, adapter_context, provides, name, **kw):
@component.adapter(adapter_context)
@@ -558,8 +539,8 @@
class ApplicationGrokker(martian.ClassGrokker):
- component_class = grok.Application
- priority = 500
+ martian.component(grok.Application)
+ martian.priority(500)
def grok(self, name, factory, module_info, config, **kw):
# XXX fail loudly if the same application name is used twice.
@@ -574,7 +555,7 @@
class IndexesGrokker(martian.InstanceGrokker):
- component_class = components.IndexesClass
+ martian.component(components.IndexesClass)
def grok(self, name, factory, module_info, config, **kw):
site = grok.site.bind().get(factory)
@@ -654,11 +635,9 @@
class SkinGrokker(martian.ClassGrokker):
- component_class = grok.Skin
- directives = [
- grok.layer.bind(default=IBrowserRequest),
- grok.name.bind(get_default=default_view_name),
- ]
+ martian.component(grok.Skin)
+ martian.directive(grok.layer, default=IBrowserRequest)
+ martian.directive(grok.name, get_default=default_view_name)
def execute(self, factory, config, name, layer, **kw):
config.action(
@@ -669,11 +648,9 @@
return True
class RESTProtocolGrokker(martian.ClassGrokker):
- component_class = grok.RESTProtocol
- directives = [
- grok.layer.bind(default=IBrowserRequest),
- grok.name.bind(get_default=default_view_name),
- ]
+ martian.component(grok.RESTProtocol)
+ martian.directive(grok.layer, default=IBrowserRequest)
+ martian.directive(grok.name, get_default=default_view_name)
def execute(self, factory, config, name, layer, **kw):
config.action(
@@ -684,13 +661,11 @@
return True
class ViewletManagerGrokker(martian.ClassGrokker):
- component_class = grok.ViewletManager
- directives = [
- grok.context.bind(),
- grok.layer.bind(default=IDefaultBrowserLayer),
- grok.view.bind(),
- grok.name.bind(),
- ]
+ martian.component(grok.ViewletManager)
+ martian.directive(grok.context)
+ martian.directive(grok.layer, default=IDefaultBrowserLayer)
+ martian.directive(grok.view)
+ martian.directive(grok.name)
def grok(self, name, factory, module_info, **kw):
# Need to store the module info object on the view class so that it
@@ -729,15 +704,13 @@
has_render, has_no_render)
class ViewletGrokker(martian.ClassGrokker):
- component_class = grok.Viewlet
- directives = [
- grok.context.bind(),
- grok.layer.bind(default=IDefaultBrowserLayer),
- grok.view.bind(),
- grok.viewletmanager.bind(),
- grok.name.bind(get_default=default_view_name),
- grok.require.bind(name='permission'),
- ]
+ martian.component(grok.Viewlet)
+ martian.directive(grok.context)
+ martian.directive(grok.layer, default=IDefaultBrowserLayer)
+ martian.directive(grok.view)
+ martian.directive(grok.viewletmanager)
+ martian.directive(grok.name, get_default=default_view_name)
+ martian.directive(grok.require, name='permission')
def grok(self, name, factory, module_info, **kw):
# Need to store the module info object on the view class so that it
Modified: grok/trunk/src/grok/tests/grokker/continue_scanning.py
===================================================================
--- grok/trunk/src/grok/tests/grokker/continue_scanning.py 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/src/grok/tests/grokker/continue_scanning.py 2008-06-11 17:24:37 UTC (rev 87316)
@@ -5,6 +5,7 @@
Here we define AlphaGrokker which has higher priority than BetaGrokker but does
not block BetaGrokker from picking up the same component::
+ >>> import grok
>>> grok.testing.grok(__name__)
In the fixture there is AlphaBetaSub that inherits from both Alpha and Beta.
@@ -15,7 +16,7 @@
beta
"""
-import grok
+import martian
class Alpha(object):
@@ -24,16 +25,16 @@
class Beta(object):
pass
-class AlphaGrokker(grok.ClassGrokker):
- component_class = Alpha
- priority = 1 # we need to go before BetaGrokker
+class AlphaGrokker(martian.ClassGrokker):
+ martian.component(Alpha)
+ martian.priority(1) # we need to go before BetaGrokker
def grok(self, name, factory, module_info, config, **kw):
print "alpha"
return True
-class BetaGrokker(grok.ClassGrokker):
- component_class = Beta
+class BetaGrokker(martian.ClassGrokker):
+ martian.component(Beta)
def grok(self, name, factory, module_info, config, **kw):
print "beta"
Modified: grok/trunk/src/grok/tests/grokker/onlyonce_fixture/_meta.py
===================================================================
--- grok/trunk/src/grok/tests/grokker/onlyonce_fixture/_meta.py 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/src/grok/tests/grokker/onlyonce_fixture/_meta.py 2008-06-11 17:24:37 UTC (rev 87316)
@@ -2,8 +2,8 @@
from component import Alpha
class AlphaGrokker(martian.ClassGrokker):
- component_class = Alpha
-
+ martian.component(Alpha)
+
def grok(self, name, factory, module_info, **kw):
print "alpha"
return True
Modified: grok/trunk/src/grok/tests/grokker/onlyonce_fixture/component.py
===================================================================
--- grok/trunk/src/grok/tests/grokker/onlyonce_fixture/component.py 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/src/grok/tests/grokker/onlyonce_fixture/component.py 2008-06-11 17:24:37 UTC (rev 87316)
@@ -1,4 +1,4 @@
-import grok
+import martian
class Alpha(object):
- grok.baseclass()
+ martian.baseclass()
Modified: grok/trunk/src/grok/tests/grokker/priority.py
===================================================================
--- grok/trunk/src/grok/tests/grokker/priority.py 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/src/grok/tests/grokker/priority.py 2008-06-11 17:24:37 UTC (rev 87316)
@@ -6,6 +6,7 @@
- BetaGrokker with priority 1
- GammaGrokker with priority -1
+ >>> import grok
>>> grok.testing.grok(__name__)
We grok a module that implements subclasses for Alpha, Beta, and Gamma and our
@@ -17,9 +18,8 @@
gamma
"""
-import grok
+import martian
-
class Alpha(object):
pass
@@ -30,25 +30,25 @@
class Gamma(object):
pass
-class AlphaGrokker(grok.ClassGrokker):
- component_class = Alpha
-
+class AlphaGrokker(martian.ClassGrokker):
+ martian.component(Alpha)
+
def grok(self, name, factory, module_info, **kw):
print "alpha"
return True
-class BetaGrokker(grok.ClassGrokker):
- component_class = Beta
- priority = 1
-
+class BetaGrokker(martian.ClassGrokker):
+ martian.component(Beta)
+ martian.priority(1)
+
def grok(self, name, factory, module_info, **kw):
print "beta"
return True
-class GammaGrokker(grok.ClassGrokker):
- component_class = Gamma
- priority = -1
-
+class GammaGrokker(martian.ClassGrokker):
+ martian.component(Gamma)
+ martian.priority(-1)
+
def grok(self, name, factory, module_info, **kw):
print "gamma"
return True
Modified: grok/trunk/versions.cfg
===================================================================
--- grok/trunk/versions.cfg 2008-06-11 17:04:13 UTC (rev 87315)
+++ grok/trunk/versions.cfg 2008-06-11 17:24:37 UTC (rev 87316)
@@ -5,8 +5,8 @@
ZConfig = 2.5.1
ZODB3 = 3.8
docutils = 0.4
-martian = 0.9.7
-grokcore.component = 1.3
+martian = 0.10
+grokcore.component = 1.4
mechanize = 0.1.7b
pytz = 2007k
simplejson = 1.7.1
More information about the Checkins
mailing list