diff --git a/composer/README.txt b/composer/README.txt index 6073211..d4d4fea 100644 --- a/composer/README.txt +++ b/composer/README.txt @@ -48,7 +48,8 @@ with the template. ... for c in self.template.components: ... print c, self.context.parts.get(c.name, '-') - >>> inst = ConfigurationAdapter(c001, desktop) + >>> inst = ConfigurationAdapter(c001) + >>> inst.template = desktop >>> inst.applyTemplate() case - mainboard - diff --git a/composer/instance.py b/composer/instance.py index 76f98c4..ebbcdad 100644 --- a/composer/instance.py +++ b/composer/instance.py @@ -30,10 +30,10 @@ from cybertools.composer.interfaces import IInstance class Instance(object): implements(IInstance) + template = None - def __init__(self, context, template): + def __init__(self, context): self.context = context - self.template = template self.instances = [] def applyTemplate(self, *args, **kw): diff --git a/composer/interfaces.py b/composer/interfaces.py index b9842d0..35e9707 100644 --- a/composer/interfaces.py +++ b/composer/interfaces.py @@ -62,7 +62,7 @@ class IInstance(Interface): """ context = Attribute('Object this instance adapter has been created for') - template = Attribute('The template to be used for this client') + template = Attribute('The template to be used for this instance') def applyTemplate(*args, **kw): """ Apply the template using the instance's context. Note that this diff --git a/composer/schema/README.txt b/composer/schema/README.txt index 20a0de9..7e02a0f 100644 --- a/composer/schema/README.txt +++ b/composer/schema/README.txt @@ -5,6 +5,35 @@ Schema and Field Management ($Id$) >>> from cybertools.composer.schema.schema import Schema - >>> from cybertools.composer.schema.instance import Instance >>> 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 -