[Zope3-Users] A gentle push in the right direction needed

Tim Penhey tim at penhey.net
Wed Jul 19 16:22:00 EDT 2006


Hi all,

I have an application that is written with Struts (Java servlet and JSP) with 
a postgresql database which I am attempting to rewrite with zope 3.

Having read over half of "Web Component Development with Zope 3" I thought it 
was high time to get started.  However I seem to have hit my first snag.

In the java app I have a customer class which has a postal address, and a list 
of delivery addresses.

So I started with:

from zope.interface import Interface
from zope.schema import TextLine

class IAddress(Interface):
    """Address details"""

    line1 = TextLine(
        title=u"Line 1",
        description=u"The first line of the address",
        required=True
        )
    line2 = TextLine(
        title=u"Line 2",
        description=u"The second line of the address",
        required=False 
        )
    city = TextLine(
        title=u"City",
        description=u"The city",
        required=False
        )
    county = TextLine(
        title=u"County",
        description=u"County for the address",
        required=False
        )

    postcode = TextLine(
        title=u"Postcode",
        description=u"Postcode of the address",
        required=False
        )

Then...

from zope.interface import Interface
from zope.schema import Bool, Float, Text, TextLine, Int, InterfaceField

class ICustomer(Interface):
    """Information about our customers"""

    id = Int(
        title=u"ID",
        description=u"The customer's unique id",
        required=True,
        min=1
        )

    name = TextLine(
        title=u"Name",
        description=u"The name of the customer",
        required=True
        )

    postal_address = InterfaceField(
        title=u"Postal Address"
        )
    
Now it is with the postal_address I hit my first snag.  I really want to say 
that it is an IAddress.  Am I using InterfaceField correctly here?  Is there 
an option to specify the type of the interface?

Also how do I specify a list of addresses?

Thanks.
Tim


More information about the Zope3-users mailing list