cybertools/composer/schema
helmutm 8ec1876315 renamed client to instance; re-build schema/README.txt
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1745 fd906abe-77d9-0310-91a1-e0d9ade77398
2007-05-18 11:08:08 +00:00
..
__init__.py starting with organize.service; new package cybertools.composer 2007-05-14 20:31:15 +00:00
field.py removed Instance; added schema package 2007-05-15 09:36:02 +00:00
instance.py renamed client to instance; re-build schema/README.txt 2007-05-18 11:08:08 +00:00
interfaces.py removed Instance; added schema package 2007-05-15 09:36:02 +00:00
README.txt renamed client to instance; re-build schema/README.txt 2007-05-18 10:17:01 +00:00
schema.py removed Instance; added schema package 2007-05-15 09:36:02 +00:00
tests.py removed Instance; added schema package 2007-05-15 09:36:02 +00:00

===========================
Schema and Field Management
===========================

  ($Id$)

  >>> from cybertools.composer.schema.schema import Schema
  >>> from cybertools.composer.schema.field import Field

We start with setting up a schema with fields.

  >>> serviceSchema = Schema()
  >>> serviceSchema.components.append(Field('title'))
  >>> serviceSchema.components.append(Field('description'))
  >>> serviceSchema.components.append(Field('start'))
  >>> serviceSchema.components.append(Field('end'))
  >>> serviceSchema.components.append(Field('capacity'))

For using a schema we need some class that we can use for creating
objects.

  >>> class Service(object):
  ...     pass

The schema will be connected with an object via an instance adapter.

  >>> from cybertools.composer.schema.instance import Editor
  >>> from zope import component
  >>> component.provideAdapter(Editor, (Service,), name="service.edit")

  >>> srv = Service()
  >>> inst = component.getAdapter(srv, name='service.edit')
  >>> inst.template = serviceSchema
  >>> inst.applyTemplate()
  title -
  description -
  start -
  end -
  capacity -