diff --git a/browser/README.txt b/browser/README.txt index d97648b..1ad344e 100644 --- a/browser/README.txt +++ b/browser/README.txt @@ -3,8 +3,12 @@ Browser View Tools We first set up a test and working environment: - >>> from zope.app import zapi - >>> from zope.app.testing import ztapi + >>> from zope.app import zapi + >>> from zope.app.testing import ztapi + + >>> from zope import component, interface + >>> from zope.publisher.browser import TestRequest + >>> from zope.publisher.interfaces.browser import IBrowserRequest The View Controller ------------------- @@ -91,3 +95,43 @@ The pre-set collection of macros for a certain slot may be extended: >>> print m5.name, m5.media, m5.resourceName css all node.css + +The View Configurator +--------------------- + +A view configurator is a multiadapter for a content object that provides +a set of properties to be used for setting up special presentation +characteristics of a page. Typical examples for such characteristics are + +- the skin to be used +- the logo to show in the corner of the page + +The default configurator uses attribute annotations for retrieving view +properties; that means that there could be form somewhere to edit those +properties and store them in the content object's annotations. + +The configurator is called automatically from the controller if there is +an appropriate adapter: + + >>> from cybertools.browser.configurator import IViewConfigurator + >>> from cybertools.browser.configurator import ViewConfigurator + >>> component.provideAdapter(ViewConfigurator, (SomeObject, IBrowserRequest), + ... IViewConfigurator) + >>> controller = Controller(view, request) + +But this does not have any effect as long as there aren't any properties +stored in the attribute annotations. So let's set a 'skinName' attribute: + + >>> from zope.app.annotation.interfaces import IAttributeAnnotatable, IAnnotations + >>> from zope.app.annotation.attribute import AttributeAnnotations + >>> interface.classImplements(SomeObject, IAttributeAnnotatable) + >>> component.provideAdapter(AttributeAnnotations, (SomeObject,), IAnnotations) + >>> ann = IAnnotations(obj) + >>> setting = {'skinName': {'value': 'SuperSkin'}} + >>> from cybertools.browser.configurator import ANNOTATION_KEY + >>> ann[ANNOTATION_KEY] = setting + + >>> controller = Controller(view, request) + >>> controller.skinName.value + 'SuperSkin' + diff --git a/browser/__init__.py b/browser/__init__.py index 12b99a0..40d2108 100644 --- a/browser/__init__.py +++ b/browser/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2005 Helmut Merz helmutm@cy55.de +# Copyright (c) 2006 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,13 +21,3 @@ cybertools browser package. $Id$ """ - -from zope.viewlet.interfaces import IViewletManager - -class ILeft(IViewletManager): - """ Left slot. - """ - -class IBody(IViewletManager): - """ Body (main) content slot. - """ diff --git a/browser/base_macros.pt b/browser/base_macros.pt index 3e33b80..ea1233f 100644 --- a/browser/base_macros.pt +++ b/browser/base_macros.pt @@ -1,3 +1,13 @@ + + Home + + +