moved client stuff to composer.schema
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1849 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
f8be0e1a0f
commit
59923d2830
2 changed files with 2 additions and 57 deletions
|
@ -132,10 +132,6 @@ class IServiceManager(Interface):
|
|||
'that have registered or want to register for '
|
||||
'services managed by this service manager.')
|
||||
|
||||
clientSchemas = Attribute('An optional collection of schema objects '
|
||||
'that describe the data fields of the client '
|
||||
'objects.')
|
||||
|
||||
def addClient(client):
|
||||
""" Add the client object given to the collection of clients.
|
||||
"""
|
||||
|
|
|
@ -29,14 +29,14 @@ from zope.interface import implements
|
|||
from cybertools.composer.interfaces import IInstance
|
||||
from cybertools.util.jeep import Jeep
|
||||
|
||||
from cybertools.composer.schema.interfaces import IClientManager
|
||||
from cybertools.organize.interfaces import IServiceManager
|
||||
from cybertools.organize.interfaces import IClient, IClientFactory
|
||||
from cybertools.organize.interfaces import IService, IScheduledService
|
||||
|
||||
|
||||
class ServiceManager(object):
|
||||
|
||||
implements(IServiceManager)
|
||||
implements(IServiceManager, IClientManager)
|
||||
|
||||
servicesFactory = list
|
||||
clientSchemasFactory = Jeep
|
||||
|
@ -90,57 +90,6 @@ class ScheduledService(Service):
|
|||
implements(IScheduledService)
|
||||
|
||||
|
||||
class Client(object):
|
||||
|
||||
implements(IClient)
|
||||
|
||||
def __init__(self, manager):
|
||||
self.manager = manager
|
||||
|
||||
|
||||
class ClientFactory(object):
|
||||
|
||||
implements(IClientFactory)
|
||||
adapts(IServiceManager)
|
||||
|
||||
def __init__(self, context):
|
||||
self.context = context
|
||||
|
||||
def __call__(self):
|
||||
return Client(self.context)
|
||||
|
||||
|
||||
class ClientInstanceAdapter(object):
|
||||
|
||||
implements(IInstance)
|
||||
adapts(IClient)
|
||||
|
||||
baseAspect = 'service.client.'
|
||||
schema = 'default'
|
||||
|
||||
@property
|
||||
def aspect(self):
|
||||
return self.baseAspect + self.schema
|
||||
|
||||
@property
|
||||
def template(self):
|
||||
return self.context.manager.clientSchemas.get(self.schema, None)
|
||||
|
||||
def __init__(self, context):
|
||||
self.context = context
|
||||
|
||||
def applyTemplate(self, data={}, schema='default', **kw):
|
||||
if getattr(self.context, 'attributes', None) is None:
|
||||
self.context.attributes = OOBTree()
|
||||
self.schema = schema
|
||||
template = self.template
|
||||
attributes = self.context.attributes.setdefault(self.aspect, OOBTree())
|
||||
if template is not None:
|
||||
for c in template.components:
|
||||
name = c.name
|
||||
attributes[name] = data.get(name, u'')
|
||||
|
||||
|
||||
class Registration(object):
|
||||
|
||||
def __init__(self, client):
|
||||
|
|
Loading…
Add table
Reference in a new issue