[Checkins] SVN: grok/branches/ksmith_mcweekly-layers-011/ updated
to work with grok 0.11, all tests pass
Kevin Smith
kevin at mcweekly.com
Fri Sep 14 19:21:30 EDT 2007
Log message for revision 79653:
updated to work with grok 0.11, all tests pass
Changed:
U grok/branches/ksmith_mcweekly-layers-011/CHANGES.txt
U grok/branches/ksmith_mcweekly-layers-011/src/grok/__init__.py
U grok/branches/ksmith_mcweekly-layers-011/src/grok/components.py
U grok/branches/ksmith_mcweekly-layers-011/src/grok/directive.py
U grok/branches/ksmith_mcweekly-layers-011/src/grok/interfaces.py
U grok/branches/ksmith_mcweekly-layers-011/src/grok/meta.py
-=-
Modified: grok/branches/ksmith_mcweekly-layers-011/CHANGES.txt
===================================================================
--- grok/branches/ksmith_mcweekly-layers-011/CHANGES.txt 2007-09-14 21:04:17 UTC (rev 79652)
+++ grok/branches/ksmith_mcweekly-layers-011/CHANGES.txt 2007-09-14 23:21:30 UTC (rev 79653)
@@ -6,6 +6,7 @@
Feature changes
---------------
+* Integrated skins and layers. grok.layer, grok.Layer, grok.Skin
* Removed grok.define_permission in favor of the grok.Permission
component base class
Modified: grok/branches/ksmith_mcweekly-layers-011/src/grok/__init__.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers-011/src/grok/__init__.py 2007-09-14 21:04:17 UTC (rev 79652)
+++ grok/branches/ksmith_mcweekly-layers-011/src/grok/__init__.py 2007-09-14 23:21:30 UTC (rev 79653)
@@ -13,7 +13,7 @@
##############################################################################
"""Grok
"""
-
+__version__ = "ksmith"
from zope.interface import implements
from zope.component import adapts
from zope.event import notify
@@ -36,9 +36,10 @@
from grok.components import Application, Form, AddForm, EditForm, DisplayForm
from grok.components import Indexes
from grok.components import Permission, Role
+from grok.components import Skin, ILayer
from grok.directive import (context, name, title, template, templatedir,
provides, baseclass, global_utility, local_utility,
- permissions, require, site)
+ permissions, require, site, layer)
from grok._grok import do_grok as grok # Avoid name clash within _grok
from grok._grok import grok_component
from grok._grok import SubscribeDecorator as subscribe
Modified: grok/branches/ksmith_mcweekly-layers-011/src/grok/components.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers-011/src/grok/components.py 2007-09-14 21:04:17 UTC (rev 79652)
+++ grok/branches/ksmith_mcweekly-layers-011/src/grok/components.py 2007-09-14 23:21:30 UTC (rev 79653)
@@ -30,6 +30,7 @@
from zope.publisher.browser import BrowserPage
from zope.publisher.interfaces import NotFound
from zope.publisher.interfaces.browser import (IBrowserPublisher,
+ IDefaultBrowserLayer,
IBrowserRequest)
from zope.publisher.publish import mapply
from zope.pagetemplate import pagetemplate, pagetemplatefile
@@ -485,3 +486,9 @@
class Role(object):
pass
+
+class ILayer(interface.Interface):
+ pass
+
+class Skin(object):
+ pass
Modified: grok/branches/ksmith_mcweekly-layers-011/src/grok/directive.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers-011/src/grok/directive.py 2007-09-14 21:04:17 UTC (rev 79652)
+++ grok/branches/ksmith_mcweekly-layers-011/src/grok/directive.py 2007-09-14 23:21:30 UTC (rev 79653)
@@ -120,3 +120,5 @@
title = SingleTextDirective('grok.title', ClassDirectiveContext())
permissions = MultiValueOnceDirective(
'grok.permissions', ClassDirectiveContext())
+layer = InterfaceOrClassDirective('grok.layer',
+ ClassOrModuleDirectiveContext())
Modified: grok/branches/ksmith_mcweekly-layers-011/src/grok/interfaces.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers-011/src/grok/interfaces.py 2007-09-14 21:04:17 UTC (rev 79652)
+++ grok/branches/ksmith_mcweekly-layers-011/src/grok/interfaces.py 2007-09-14 23:21:30 UTC (rev 79653)
@@ -42,6 +42,8 @@
EditForm = interface.Attribute("Base class for edit forms.")
DisplayForm = interface.Attribute("Base class for display forms.")
Indexes = interface.Attribute("Base class for catalog index definitions.")
+ Layer = interface.Attribute("Base interface for layers.")
+ Skin = interface.Attribute("Base class for skin.")
class IGrokErrors(interface.Interface):
@@ -76,6 +78,17 @@
This directive can only be used on class level."""
+ def layer(layer):
+ """Declare the layer for the view.
+
+ This directive acts as a contraint on the 'request' of
+ grok.View. This directive can only be used on class level."""
+
+ def skin(skin):
+ """Declare this layer as a named skin.
+
+ This directive can only be used on class level."""
+
def template(template):
"""Declare the template name for a view.
Modified: grok/branches/ksmith_mcweekly-layers-011/src/grok/meta.py
===================================================================
--- grok/branches/ksmith_mcweekly-layers-011/src/grok/meta.py 2007-09-14 21:04:17 UTC (rev 79652)
+++ grok/branches/ksmith_mcweekly-layers-011/src/grok/meta.py 2007-09-14 23:21:30 UTC (rev 79653)
@@ -19,7 +19,8 @@
from zope import interface, component
from zope.publisher.interfaces.browser import (IDefaultBrowserLayer,
IBrowserRequest,
- IBrowserPublisher)
+ IBrowserPublisher,
+ IBrowserSkinType)
from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
from zope.security.permission import Permission
from zope.security.interfaces import IPermission
@@ -142,6 +143,7 @@
component_class = grok.View
def grok(self, name, factory, context, module_info, templates):
+
view_context = util.determine_class_context(factory, context)
factory.module_info = module_info
@@ -191,12 +193,17 @@
raise GrokError("View %r has no associated template or "
"'render' method." % factory, factory)
+ # grab layer, if there is one
+ view_layer = util.class_annotation(factory, 'grok.layer',
+ None) or module_info.getAnnotation('grok.layer',
+ None) or IDefaultBrowserLayer
+
view_name = util.class_annotation(factory, 'grok.name',
factory_name)
# __view_name__ is needed to support IAbsoluteURL on views
factory.__view_name__ = view_name
component.provideAdapter(factory,
- adapts=(view_context, IDefaultBrowserLayer),
+ adapts=(view_context, view_layer),
provides=interface.Interface,
name=view_name)
@@ -631,6 +638,7 @@
"""Create the catalog if needed and return it.
If the catalog already exists, return that.
+
"""
catalog = zope.component.queryUtility(
ICatalog, name=self.catalog_name, context=site, default=None)
@@ -650,3 +658,20 @@
intids = IntIds()
setupUtility(site, intids, IIntIds)
return intids
+
+
+class ILayerGrokker(martian.ClassGrokker):
+ component_class = grok.ILayer
+
+
+class SkinGrokker(martian.ClassGrokker):
+ component_class = grok.Skin
+
+ def grok(self, name, factory, context, module_info, templates):
+
+ layer = util.class_annotation(factory, 'grok.layer',
+ None) or module_info.getAnnotation('grok.layer',
+ None) or IBrowserRequest
+ name = grok.util.class_annotation(factory, 'grok.name', factory.__name__.lower())
+ zope.component.interface.provideInterface(name, layer, IBrowserSkinType)
+ return True
More information about the Checkins
mailing list