[Zope3-Users] Dynamically generate interfaces, content object and z3c.forms?
Harald
Harald.Gantioler at proclos.com
Wed Aug 20 05:15:14 EDT 2008
Hello,
I need some advise how to use dynamically generated interfaces, content
and forms:
1. step:
generate interfaces from xsd
I've used zope.interface.interface.InterfaceClass to achieve this
2. step:
generate content object implementing the generated interface from step 1
zope.interface.directlyProvides or classImplements?
FieldProperty?
3. step:
generate z3c.forms with subforms(depending on interface complexity)
There are 3 different types of forms in my use chase:
a) simple interface, with simple attributes
b) interface with zope.schema.Object to display
c) interface with zope.schema.Dict and zope.schema.Object as value_type
d) interface with zope.schema.List and zope.schema.Object as value_type
but how?
I've looked at the addressbook example in z3c.form but ...
I'm still missing infos/knowledge about how to connect the three steps
Help/Advice appreciated.
Actually I'm pretty lost. ;-)
Thanks!
Example interfaces :
class IProject(IContained):
name= zope.schema.TextLine(
title=u'Name',
description=u'Name',
required=True,
)
version=zope.schema.TextLine(
title=u'Version',
description=u'Version',
required=False,
)
comment=zope.schema.Text(
title=u'Comment',
description=u'Comment',
required=False,
)
contexts=zope.schema.Dict(
title=u'Contexts',
description=u'Contexts',
key_type=zope.schema.TextLine(__name__='contextName',title=u'Name',
description=u'Name',required=True),
value_type=zope.schema.Object(schema=IContext),
required=False,
)
connections=zope.schema.Dict(
title=u'Connections',
description=u'Connections',
key_type=zope.schema.Object(schema=INameTypeConnection,
__name__='connectionnametype'),
value_type=zope.schema.Object(schema=IConnection),
required=False,
)
aliasmaps=zope.schema.Dict(
title=u'Alias Maps',
description=u'Alias Maps',
key_type=zope.schema.TextLine(__name__='aliasmapName',
title=u'Name',description=u'Name',
required=True,default=u'default'),
value_type=zope.schema.Object(schema=IAliasMap),
required=False,
)
sources=zope.schema.Dict(
title=u'Sources',
description=u'Sources',
key_type=zope.schema.Object(schema=INameTypeSource,
__name__='sourcenametype'),
value_type=zope.schema.Object(schema=ISource),
required=False,
)
jobs=zope.schema.Dict(
title=u'Jobs',
description=u'Jobs',
key_type=zope.schema.TextLine(__name__='jobName',
title=u'Name',description=u'Name',
required=True,default=u'default'),
value_type=zope.schema.Object(schema=IJob),
required=False,
)
class IConnection(zope.interface.Interface):
""" generic Connection Interface
"""
class IDefaultConnection(IConnection):
""" a connection
"""
host=zope.schema.TextLine(
title=u'host',
description=u'host',
required=False,
)
port=zope.schema.Int(
title=u'port',
description=u'port',
required=False,
)
user=zope.schema.TextLine(
title=u'user',
description=u'user',
required=False,
)
password=zope.schema.Password(
title=u'password',
description=u'password',
required=False
)
database=zope.schema.TextLine(
title=u'database',
description=u'database',
required=False,
)
language=zope.schema.TextLine(
title=u'language',
description=u'language',
required=False,
)
parameters=zope.schema.List(
title=u'parameters',
description=u'parameters',
required=False,
value_type=zope.schema.Object(schema=IParameter),
)
comment=zope.schema.Text(
title=u'comment',
description=u'comment',
required=False,
)
More information about the Zope3-users
mailing list