diff --git a/browser/interfaces.py b/browser/interfaces.py
new file mode 100644
index 0000000..790e1cb
--- /dev/null
+++ b/browser/interfaces.py
@@ -0,0 +1,38 @@
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+"""
+Interfaces for the cybertools.browser package.
+
+$Id$
+"""
+
+from zope.interface import Interface, Attribute
+
+
+class IRenderers(Interface):
+ """ Provides a dictionary of renderers.
+
+ A typical implementation is provided by the ``macros`` attribute
+ of a Zope Page Template.
+ """
+
+class IRenderer(Interface):
+ """ Marker interface for a renderer, e.g. a ZPT macro.
+ """
+
diff --git a/composer/schema/README.txt b/composer/schema/README.txt
index 995b996..f048e03 100644
--- a/composer/schema/README.txt
+++ b/composer/schema/README.txt
@@ -161,3 +161,10 @@ Create a new object using a schema-based form
>>> p2.lastName, p2.age
(u'Smith', 28)
+Macros / renderers
+------------------
+
+ >>> fieldRenderers = form.fieldRenderers
+ >>> sorted(fieldRenderers.keys())
+ [u'field', u'field_spacer', u'fields', u'input_dropdown', u'input_fileupload',
+ u'input_password', u'input_textarea', u'input_textline']
diff --git a/composer/schema/browser/form.py b/composer/schema/browser/form.py
index 3d2c87e..f80b9cc 100644
--- a/composer/schema/browser/form.py
+++ b/composer/schema/browser/form.py
@@ -22,7 +22,7 @@ View(s) for forms based on composer.schema.
$Id$
"""
-from zope import component
+from zope import component, interface
from zope.app.container.interfaces import INameChooser
from zope.cachedescriptors.property import Lazy
from zope.interface import Interface
@@ -30,6 +30,7 @@ from zope.event import notify
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
from zope.traversing.browser.absoluteurl import absoluteURL
+from cybertools.browser.interfaces import IRenderers
from cybertools.composer.interfaces import IInstance
from cybertools.composer.schema.browser.common import schema_macros, schema_edit_macros
from cybertools.composer.schema.interfaces import ISchemaFactory
@@ -47,12 +48,17 @@ class Form(object):
self.context = context
self.request = request
- @property
+ @Lazy
def schemaMacros(self):
return schema_macros.macros
- @property
- def schemaEditMacros(self):
+ # proof-of-concept - get a dictionary of renderers (macros) via adaptatation
+ @Lazy
+ def fieldRenderers(self):
+ return IRenderers(self)
+
+ @Lazy
+ def fieldEditRenderers(self):
return schema_edit_macros.macros
@Lazy
@@ -151,3 +157,12 @@ class CreateForm(Form):
def getName(self, obj):
name = getattr(obj, 'name', getattr(obj, 'title'))
return INameChooser(container).chooseName(name, obj)
+
+
+# proof-of-concept - define a dictionary of renderers (macros) as an adapter
+@interface.implementer(IRenderers)
+@component.adapter(Form)
+def getFormSchemaRenderers(view):
+ return schema_macros.macros
+component.provideAdapter(getFormSchemaRenderers)
+
diff --git a/composer/schema/browser/schema_macros.pt b/composer/schema/browser/schema_macros.pt
index c50d19f..dc1e76f 100755
--- a/composer/schema/browser/schema_macros.pt
+++ b/composer/schema/browser/schema_macros.pt
@@ -11,12 +11,12 @@