renamed client to instance; re-build schema/README.txt

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1744 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2007-05-18 10:17:01 +00:00
parent 151c0c86cf
commit da739765d8
4 changed files with 35 additions and 5 deletions

View file

@ -48,7 +48,8 @@ with the template.
... for c in self.template.components: ... for c in self.template.components:
... print c, self.context.parts.get(c.name, '-') ... print c, self.context.parts.get(c.name, '-')
>>> inst = ConfigurationAdapter(c001, desktop) >>> inst = ConfigurationAdapter(c001)
>>> inst.template = desktop
>>> inst.applyTemplate() >>> inst.applyTemplate()
case - case -
mainboard - mainboard -

View file

@ -30,10 +30,10 @@ from cybertools.composer.interfaces import IInstance
class Instance(object): class Instance(object):
implements(IInstance) implements(IInstance)
template = None
def __init__(self, context, template): def __init__(self, context):
self.context = context self.context = context
self.template = template
self.instances = [] self.instances = []
def applyTemplate(self, *args, **kw): def applyTemplate(self, *args, **kw):

View file

@ -62,7 +62,7 @@ class IInstance(Interface):
""" """
context = Attribute('Object this instance adapter has been created for') 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): def applyTemplate(*args, **kw):
""" Apply the template using the instance's context. Note that this """ Apply the template using the instance's context. Note that this

View file

@ -5,6 +5,35 @@ Schema and Field Management
($Id$) ($Id$)
>>> from cybertools.composer.schema.schema import Schema >>> from cybertools.composer.schema.schema import Schema
>>> from cybertools.composer.schema.instance import Instance
>>> from cybertools.composer.schema.field import Field >>> 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 -