work in progress: composer.schema, organize.service for tumsm
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1853 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
78cd39eb12
commit
53acc23802
4 changed files with 45 additions and 15 deletions
|
@ -24,7 +24,6 @@ $Id$
|
||||||
|
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.traversing.browser import absoluteURL
|
|
||||||
|
|
||||||
from cybertools.composer.interfaces import IInstance
|
from cybertools.composer.interfaces import IInstance
|
||||||
from cybertools.composer.schema.interfaces import IClientFactory
|
from cybertools.composer.schema.interfaces import IClientFactory
|
||||||
|
@ -32,10 +31,11 @@ from cybertools.composer.schema.interfaces import IClientFactory
|
||||||
|
|
||||||
class SchemaView(object):
|
class SchemaView(object):
|
||||||
|
|
||||||
|
clientName = None
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.request = request
|
self.request = request
|
||||||
self.clientName = None
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def fields(self):
|
def fields(self):
|
||||||
|
@ -43,12 +43,17 @@ class SchemaView(object):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def data(self):
|
def data(self):
|
||||||
form = self.request.form
|
return self.getData()
|
||||||
clientName = self.clientName = form.get('id')
|
|
||||||
|
def getData(self):
|
||||||
|
if not self.clientName:
|
||||||
|
form = self.request.form
|
||||||
|
self.clientName = form.get('id')
|
||||||
|
clientName = self.clientName
|
||||||
if not clientName:
|
if not clientName:
|
||||||
return {}
|
return {}
|
||||||
manager = self.context.manager
|
manager = self.context.getManager()
|
||||||
client = manager.clients.get(clientName)
|
client = manager.getClients().get(clientName)
|
||||||
if client is None:
|
if client is None:
|
||||||
return {}
|
return {}
|
||||||
instance = IInstance(client)
|
instance = IInstance(client)
|
||||||
|
@ -57,14 +62,15 @@ class SchemaView(object):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
form = self.request.form
|
form = self.request.form
|
||||||
|
if not self.clientName:
|
||||||
|
self.clientName = form.get('id')
|
||||||
|
clientName = self.clientName
|
||||||
if not form.get('action'):
|
if not form.get('action'):
|
||||||
return True
|
return True
|
||||||
manager = self.context.manager
|
manager = self.context.getManager()
|
||||||
clientName = form.get('id')
|
|
||||||
if clientName:
|
if clientName:
|
||||||
client = manager.clients.get(clientName)
|
client = manager.getClients().get(clientName)
|
||||||
if client is None:
|
if client is None:
|
||||||
# TODO: provide error message (?)
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
client = IClientFactory(manager)()
|
client = IClientFactory(manager)()
|
||||||
|
@ -72,10 +78,12 @@ class SchemaView(object):
|
||||||
instance = component.getAdapter(client, IInstance, name='editor')
|
instance = component.getAdapter(client, IInstance, name='editor')
|
||||||
instance.template = self.context
|
instance.template = self.context
|
||||||
instance.applyTemplate(form)
|
instance.applyTemplate(form)
|
||||||
self.request.response.redirect(self.nextUrl)
|
return True
|
||||||
return False
|
#self.request.response.redirect(self.nextUrl)
|
||||||
|
#return False
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def nextUrl(self):
|
def nextUrl(self):
|
||||||
|
from zope.traversing.browser import absoluteURL
|
||||||
url = absoluteURL(self.context, self.request)
|
url = absoluteURL(self.context, self.request)
|
||||||
return '%s/thank_you?id=%s' % (url, self.clientName)
|
return '%s/thankyou.html?id=%s' % (url, self.clientName)
|
||||||
|
|
|
@ -16,4 +16,11 @@
|
||||||
name="index.html"
|
name="index.html"
|
||||||
for="cybertools.composer.schema.interfaces.ISchema" />
|
for="cybertools.composer.schema.interfaces.ISchema" />
|
||||||
|
|
||||||
|
<page
|
||||||
|
for="cybertools.composer.schema.interfaces.ISchema"
|
||||||
|
name="thankyou.html"
|
||||||
|
class="cybertools.composer.schema.browser.base.SchemaView"
|
||||||
|
permission="zope.View"
|
||||||
|
/>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
|
@ -37,8 +37,12 @@ class Schema(Template):
|
||||||
manager = None
|
manager = None
|
||||||
|
|
||||||
def __init__(self, *fields, **kw):
|
def __init__(self, *fields, **kw):
|
||||||
self.name = kw.get('name', u'')
|
name = kw.get('name', None)
|
||||||
self.manager = self.__parent__ = kw.get('manager', None)
|
if name is not None:
|
||||||
|
self.name = name
|
||||||
|
manager = kw.get('manager', None)
|
||||||
|
if manager is not None:
|
||||||
|
self.manager = self.__parent__ = manager
|
||||||
super(Schema, self).__init__()
|
super(Schema, self).__init__()
|
||||||
for f in fields:
|
for f in fields:
|
||||||
self.components.append(f)
|
self.components.append(f)
|
||||||
|
@ -50,3 +54,6 @@ class Schema(Template):
|
||||||
@property
|
@property
|
||||||
def __name__(self):
|
def __name__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def getManager(self):
|
||||||
|
return self.manager
|
||||||
|
|
|
@ -54,6 +54,9 @@ class ServiceManager(object):
|
||||||
def clients(self):
|
def clients(self):
|
||||||
return self.clientsFactory()
|
return self.clientsFactory()
|
||||||
|
|
||||||
|
def getClients(self):
|
||||||
|
return self.clients
|
||||||
|
|
||||||
def addClient(self, client):
|
def addClient(self, client):
|
||||||
name = self.generateClientName(client)
|
name = self.generateClientName(client)
|
||||||
self.clients[name] = client
|
self.clients[name] = client
|
||||||
|
@ -97,3 +100,8 @@ class Registration(object):
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
|
|
||||||
|
class RegistrationTemplate(object):
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue