[Checkins] SVN: grok/branches/ksmith_mcweekly-layers/src/grok/ *
update API: grok.register_skin(layer,
name=None). If the 'name' parameter is omitted,
layer.__name__ is taken
Kevin Smith
kevin at mcweekly.com
Wed Apr 18 15:48:59 EDT 2007
Log message for revision 74241:
* update API: grok.register_skin(layer, name=None). If the 'name' parameter is omitted, layer.__name__ is taken
* updated tests
Changed:
U grok/branches/ksmith_mcweekly-layers/src/grok/directive.py
U grok/branches/ksmith_mcweekly-layers/src/grok/ftests/static/simple.py
U grok/branches/ksmith_mcweekly-layers/src/grok/ftests/static/simple_fixture/ellie.py
U grok/branches/ksmith_mcweekly-layers/src/grok/ftests/view/layer.py
U grok/branches/ksmith_mcweekly-layers/src/grok/meta.py
-=-
Modified: grok/branches/ksmith_mcweekly-layers/src/grok/directive.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers/src/grok/directive.py 2007-04-18 18:23:01 UTC (rev 74240)
+++ grok/branches/ksmith_mcweekly-layers/src/grok/directive.py 2007-04-18 19:48:59 UTC (rev 74241)
@@ -200,22 +200,19 @@
class RegisterSkinDirective(MultipleTimesDirective):
- def check_arguments(self, name, iface):
- if not name:
- raise GrokImportError("First argument cannot be an empty string"
- "of %s." % self.name)
- if not IInterface.providedBy(iface):
- raise GrokImportError("You can only pass an interface as the "
- "second argument of %s." % self.name)
+ def check_arguments(self, layer, name=None):
+ if not IInterface.providedBy(layer):
+ raise GrokImportError("You can only pass an Interface as "
+ "first argument of %s." % self.name)
def value_factory(self, *args, **kw):
return RegisterSkinInfo(*args, **kw)
class RegisterSkinInfo(object):
- def __init__(self, name, iface):
+ def __init__(self, layer, name=None):
+ self.layer = layer
self.name = name
- self.iface = iface
class GlobalUtilityDirective(MultipleTimesDirective):
Modified: grok/branches/ksmith_mcweekly-layers/src/grok/ftests/static/simple.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers/src/grok/ftests/static/simple.py 2007-04-18 18:23:01 UTC (rev 74240)
+++ grok/branches/ksmith_mcweekly-layers/src/grok/ftests/static/simple.py 2007-04-18 19:48:59 UTC (rev 74241)
@@ -48,13 +48,13 @@
>>> print browser.contents
stick figures
- >>> browser.open('http://localhost/++skin++Mammoth/ellie/@@tarpit')
+ >>> browser.open('http://localhost/++skin++MammothSkin/ellie/@@tarpit')
>>> print browser.contents
inky darkness all around
Static layer is not available to custom layers unless they subclass IDefaultBrowserLayer
- >>> browser.open('http://localhost/++skin++Mammoth/@@/grok.ftests.static.simple_fixture/subdir/otherfile.txt')
+ >>> browser.open('http://localhost/++skin++MammothSkin/@@/grok.ftests.static.simple_fixture/subdir/otherfile.txt')
Traceback (most recent call last):
...
NotFound: ...
Modified: grok/branches/ksmith_mcweekly-layers/src/grok/ftests/static/simple_fixture/ellie.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers/src/grok/ftests/static/simple_fixture/ellie.py 2007-04-18 18:23:01 UTC (rev 74240)
+++ grok/branches/ksmith_mcweekly-layers/src/grok/ftests/static/simple_fixture/ellie.py 2007-04-18 19:48:59 UTC (rev 74241)
@@ -13,10 +13,10 @@
</body>
</html>""")
-class MammothSkinLayer(grok.Layer):
+class MammothSkin(grok.Layer):
pass
-grok.register_skin('Mammoth', MammothSkinLayer)
+grok.register_skin(MammothSkin)
class CaveDrawings(grok.View):
@@ -24,7 +24,7 @@
return "stick figures"
class TarPit(grok.View):
- grok.layer(MammothSkinLayer)
+ grok.layer(MammothSkin)
def render(self):
return "inky darkness all around"
Modified: grok/branches/ksmith_mcweekly-layers/src/grok/ftests/view/layer.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers/src/grok/ftests/view/layer.py 2007-04-18 18:23:01 UTC (rev 74240)
+++ grok/branches/ksmith_mcweekly-layers/src/grok/ftests/view/layer.py 2007-04-18 19:48:59 UTC (rev 74241)
@@ -35,10 +35,10 @@
grok.layer(IBasicSkin)
-class MySkinLayer(grok.Layer):
+class MySkin(grok.Layer):
pass
-grok.register_skin('MySkin', MySkinLayer)
+grok.register_skin(MySkin)
class Mammoth(grok.Model):
pass
@@ -61,7 +61,7 @@
return "Pretty"
class EvenMoreDrawings(grok.View):
- grok.layer(MySkinLayer)
+ grok.layer(MySkin)
def render(self):
return "Awesome"
Modified: grok/branches/ksmith_mcweekly-layers/src/grok/meta.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers/src/grok/meta.py 2007-04-18 18:23:01 UTC (rev 74240)
+++ grok/branches/ksmith_mcweekly-layers/src/grok/meta.py 2007-04-18 19:48:59 UTC (rev 74241)
@@ -299,7 +299,10 @@
infos = module_info.getAnnotation('grok.register_skin',[])
if infos:
for skin in infos:
- zope.component.interface.provideInterface(skin.name, skin.iface,
+ name = skin.name
+ if not skin.name:
+ name = skin.layer.__name__
+ zope.component.interface.provideInterface(name, skin.layer,
IBrowserSkinType)
More information about the Checkins
mailing list