renamed client to instance; re-build schema/README.txt
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1742 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
993f523696
commit
03826fef10
4 changed files with 17 additions and 17 deletions
|
@ -5,7 +5,7 @@ Composer - Building Complex Structures with Templates or Schemas
|
|||
($Id$)
|
||||
|
||||
>>> from cybertools.composer.base import Element, Compound, Template
|
||||
>>> from cybertools.composer.client import Client
|
||||
>>> from cybertools.composer.instance import Instance
|
||||
|
||||
We set up a very simple demonstration system using a PC configurator.
|
||||
We start with two classes denoting a configuration and a simple
|
||||
|
@ -40,16 +40,16 @@ We need another class denoting the product that will be created.
|
|||
|
||||
>>> c001 = Product('c001')
|
||||
|
||||
The real stuff will be done by a client adpater that connects the product
|
||||
The real stuff will be done by an instance adpater that connects the product
|
||||
with the template.
|
||||
|
||||
>>> class ConfigurationAdapter(Client):
|
||||
>>> class ConfigurationAdapter(Instance):
|
||||
... def applyTemplate(self):
|
||||
... for c in self.template.components:
|
||||
... print c, self.context.parts.get(c.name, '-')
|
||||
|
||||
>>> client = ConfigurationAdapter(c001, desktop)
|
||||
>>> client.applyTemplate()
|
||||
>>> inst = ConfigurationAdapter(c001, desktop)
|
||||
>>> inst.applyTemplate()
|
||||
case -
|
||||
mainboard -
|
||||
cpu -
|
||||
|
@ -58,7 +58,7 @@ with the template.
|
|||
If we have configured a CPU for our configuration this will be listed.
|
||||
|
||||
>>> c001.parts['cpu'] = Product('z80')
|
||||
>>> client.applyTemplate()
|
||||
>>> inst.applyTemplate()
|
||||
case -
|
||||
mainboard -
|
||||
cpu z80
|
||||
|
|
|
@ -24,12 +24,12 @@ $Id$
|
|||
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.composer.interfaces import IClient
|
||||
from cybertools.composer.interfaces import IInstance
|
||||
|
||||
|
||||
class Client(object):
|
||||
class Instance(object):
|
||||
|
||||
implements(IClient)
|
||||
implements(IInstance)
|
||||
|
||||
def __init__(self, context, template):
|
||||
self.context = context
|
|
@ -55,18 +55,18 @@ class ITemplate(Interface):
|
|||
'object is built upon')
|
||||
|
||||
|
||||
# client side
|
||||
# instances
|
||||
|
||||
class IClient(Interface):
|
||||
""" Represents an object that uses a set of templates via its instances.
|
||||
class IInstance(Interface):
|
||||
""" Represents (adapts) an object that uses a template.
|
||||
"""
|
||||
|
||||
context = Attribute('Object this client 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')
|
||||
|
||||
def applyTemplate(*args, **kw):
|
||||
""" Apply the template using the client's context. Note that this
|
||||
method is just an example - client classes may define
|
||||
""" Apply the template using the instance's context. Note that this
|
||||
method is just an example - instance classes may define
|
||||
other methods that provide more specific actions.
|
||||
"""
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ $Id$
|
|||
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.composer.client import Client
|
||||
from cybertools.composer.instance import Instance
|
||||
|
||||
|
||||
class Editor(Client):
|
||||
class Editor(Instance):
|
||||
|
||||
def applyTemplate(self, data={}, *args, **kw):
|
||||
for c in self.template.components:
|
Loading…
Add table
Reference in a new issue