From a9b3f303fac97937be0616acdff9088763340c8e Mon Sep 17 00:00:00 2001 From: helmutm Date: Sun, 19 Aug 2007 14:42:32 +0000 Subject: [PATCH] provide findRegistrationTemplate() method for ServiceManagerView git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1934 fd906abe-77d9-0310-91a1-e0d9ade77398 --- organize/browser/service.py | 12 +++++++++++- organize/service.py | 6 +----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/organize/browser/service.py b/organize/browser/service.py index 341899e..25f9c6f 100644 --- a/organize/browser/service.py +++ b/organize/browser/service.py @@ -25,7 +25,7 @@ $Id$ from zope import component from zope.cachedescriptors.property import Lazy -from cybertools.organize.interfaces import IClientRegistrations +from cybertools.organize.interfaces import IClientRegistrations, IRegistrationTemplate from cybertools.composer.schema.browser.common import BaseView from cybertools.composer.schema.interfaces import IClientFactory @@ -36,6 +36,16 @@ class ServiceManagerView(object): self.context = context self.request = request + def findRegistrationTemplate(self, service): + """ Find a registration template that provides the registration + for the service given. + """ + for tpl in self.context.getClientSchemas(): + if IRegistrationTemplate.providedBy(tpl): + # TODO: check that service is really provided by this template + return tpl + return None + class ServiceView(object): diff --git a/organize/service.py b/organize/service.py index 8aad01f..1cf1805 100644 --- a/organize/service.py +++ b/organize/service.py @@ -49,8 +49,6 @@ class ServiceManager(object): services = None clients = None - #clientNum = 0 - def __init__(self): if self.servicesFactory is not None: self.services = self.servicesFactory() @@ -78,11 +76,9 @@ class ServiceManager(object): def generateClientName(self, client): return generateName(self.checkClientName) - #self.clientNum += 1 - #return '%05i' % self.clientNum def checkClientName(self, name): - return not name in self.getClients() + return name not in self.getClients() class Service(object):