Here is an example that gives me the IInputWidget errors when I use the contains/containers approach:
...interfaces.py...

class ICRM(IContainer):
    """Just a blank container to hold customers."""
    contains('.ICustomer')

class ICustomer(IContainer,IContained):
    """A basic customer."""
    contains('.IService')
    containers(ICRM)

    salesperson = Choice(
        title = _(u'Sales Person'),
description = _(u'The sales person responsible for this account.'),
        vocabulary = "Sales Person",
        required=True)

    supportperson = Choice(
        title = _(u'Support Person'),
description = _(u'The support person responsible for this account.'),
        vocabulary = "Support Person",
        required=True)

class IService(IContained):
    """A service provided by the company."""
    containers(ICustomer)

    approveddate = Date(
        title=_(u"Approved Date(YYYY-MM-DD)"),
description=_(u"The date this service was approved by finance."),
        required=False)

...
class CRM(BTreeContainer):
    """Just a blank container to hold customers."""
    implements(interfaces.ICRM)

class Customer(BTreeContainer):
    implements(interfaces.ICustomer)
    salesperson = u''
    supportperson = u''

class Service(BTreeContainer):
    implements(interfaces.IService)
    approveddate = u''
...


On Jan 26, 2007, at 9:24 PM, Marius Gedminas wrote:

On Fri, Jan 26, 2007 at 07:48:36PM +0100, David Johnson wrote:
When setting up container/contained relationships, what is the proper
approach? Is it the approach outlined in Stephan's book with
IContainer, __setitem__, and preconditions?  Or is it "contains" and
"containers"?

contains() and containers() is a newer and prettier way to achieve the
same result.  It didn't exist when Stephan's book was written.

I have been having some problems and would be curious the definitive
approach.  The former is more complicated and so I find make lots of
coding errors.  The latter is simple but I find it causes strange
IInputWidget errors.

Could you show us some code?

Marius Gedminas
--
"Nuclear war can ruin your whole compile."
                -- Karl Lehenbauer
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to