From jim at zope.com Sun Dec 1 08:32:21 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2 Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2 - New directory Message-ID: <200212011332.gB1DWLa01205@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2 In directory cvs.zope.org:/tmp/cvs-serv1199/Chapter2 Log Message: Directory /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2 added to the repository === Added directory Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2 === From jim at zope.com Sun Dec 1 08:32:43 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1 Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1 - New directory Message-ID: <200212011332.gB1DWhD01227@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1 In directory cvs.zope.org:/tmp/cvs-serv1221/Step1 Log Message: Directory /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1 added to the repository === Added directory Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1 === From jim at zope.com Sun Dec 1 08:34:40 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1 - Contact.py:1.1 ContactAdd.py:1.1 ContactAddView.py:1.1 ContactCityState.py:1.1 ContactInfoView.py:1.1 IContact.py:1.1 IPostal.py:1.1 __init__.py:1.1 add.pt:1.1 configure.zcml:1.1 contact.gif:1.1 contact_product_uml.txt:1.1 info.pt:1.1 products.zcml:1.1 stubpostal.py:1.1 Message-ID: <200212011334.gB1DYet01575@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1 In directory cvs.zope.org:/tmp/cvs-serv1554/Step1 Added Files: Contact.py ContactAdd.py ContactAddView.py ContactCityState.py ContactInfoView.py IContact.py IPostal.py __init__.py add.pt configure.zcml contact.gif contact_product_uml.txt info.pt products.zcml stubpostal.py Log Message: Updated contact example to use schemas and forms === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/Contact.py === import Persistence from IContact import IContact class Contact (Persistence.Persistent): """Personal contact information Contacts keep track of personal data, such as name, email and postal address. All methods are protected. """ __implements__ = IContact def __init__(self, first='', last='', email='', address='', pc=''): self.first = first self.last = last self.email = email self.address = address self.postalCode = pc def name(self): return "%s %s" % (self.first, self.last) === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/ContactAdd.py === from Zope.App.OFS.Container.IAdding import IAdding from Contact import Contact from Zope.Event import publish from Zope.Event.ObjectEvent import ObjectCreatedEvent from Interface import Interface class IContactAdd(Interface): """Add context using IAdding objects """ def add(first, last, email, address, pc): """Add a contact initialized from the given arguments """ class ContactAdd: "Provide a user interface for adding a contact" # Assert that we can only be applied to IAdding __used_for__ = IAdding __implements__ = IContactAdd def __init__(self, context): self.context = context def add(self, data): contact = Contact() for name in data: setattr(contact, name, data[name]) publish(self.context.context, ObjectCreatedEvent(contact)) self.context.add(contact) === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/ContactAddView.py === from Zope.Publisher.Browser.BrowserView import BrowserView from Zope.App.OFS.Container.IAdding import IAdding from Zope.ComponentArchitecture import getAdapter from ContactAdd import IContactAdd from IContact import IContact from Zope.App.Forms.Utility import setUpWidgets, getWidgetsData class ContactAddView(BrowserView): "Provide a user interface for adding a contact" # Assert that we can only be applied to IAdding __used_for__ = IAdding def __init__(self, *args): super(ContactAddView, self).__init__(*args) setUpWidgets(self, IContact) # action method def action(self): "Add a contact" data = getWidgetsData(self, IContact) getAdapter(self.context, IContactAdd).add(data) self.request.response.redirect(self.context.nextURL()) === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/ContactCityState.py === from IPostal import IPostalLookup, IPostalInfo from IContact import IContact from Zope.ComponentArchitecture import getUtility class ContactCityState: "Provide access to city and state information for a contact" __implements__ = IPostalInfo __used_for__ = IContact def __init__(self, contact): self._contact = contact lookup = getUtility(contact, IPostalLookup) info = lookup.lookup(contact.postalCode) if info is None: self._city, self._state = '', '' else: self._city, self._state = info.city(), info.state() def city(self): return self._city def state(self): return self._state === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/ContactInfoView.py === from Zope.ComponentArchitecture import getAdapter from IContact import IContact from IPostal import IPostalInfo class ContactInfoView: """Provide an interface for viewing a contact """ __used_for__ = IContact def __init__(self, context, request): self.context = context self.request = request self.info = getAdapter(context, IPostalInfo) def city(self): return self.info.city() def state(self): return self.info.state() === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/IContact.py === import re from Interface import Interface from Zope.Schema import Text, TextLine class IContact(Interface): "Provides access to basic contact information." first = TextLine(title=u"First name") last = TextLine(title=u"Last name") email = TextLine(title=u"Electronic mail address") address = Text(title=u"Postal address") postalCode = TextLine(title=u"Postal code", constraint=re.compile("\d{5,5}(-\d{4,4})?$").match) def name(): """Gets the contact name. The contact name is the first and last name""" === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/IPostal.py === from Interface import Interface class IPostalInfo(Interface): "Provide information for postal codes" def city(): """Return the city associated with the postal code. An empty string is returned if the city is unknown. """ def state(): """Return the state associated with the postal code. An empty string is returned if the state is unknown. """ class IPostalLookup(Interface): "Provide postal code lookup" def lookup(postal_code): """Lookup information for a postal code. An IPostalInfo is returned if the postal code is known. None is returned otherwise. """ === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/__init__.py === === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/add.pt === Add contact
Enter the information about the contact.
First name
Last name
Email
Address
Postal Code
=== Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/configure.zcml === === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/contact.gif === === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/contact_product_uml.txt === <> ---------- | Lookup | ---------- | o IPostalLookup o IPostalInfo ^ | : <> : -------------------- : | ContactCityState |- - - - + -------------------- : : : : <> v IContactInfo ------------------- o<- - - - - - - - - - - - - - - - - - -| ContactInfoView | ^ --------^---------- : V : | : | <> : <> ----------- : ----------- | info.pt | : | edit.pt | ----------- : ----------- : | : ^ <> : IContact --------V---------- o<- - - - - - -| ContactEditView | | ------------------- | ----------- | Contact | ----------- Key: o Interface (catalysis style) ^ V Aggregation <- - - + Dependency : o<- - -o Interface B specializes interface A A B <> Stereotype -------- | name | Class -------- === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/info.pt === Contact Information
Contact information
Name: First Last
Address: Mailing address here
Email: foo@bar.com
City: City
State: State
=== Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/products.zcml === === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/Step1/stubpostal.py === # Stub postal utility implemantation from IPostal import IPostalLookup, IPostalInfo class Info: __implements__ = IPostalInfo def __init__(self, city, state): self._city, self._state = city, state def city(self): return self._city def state(self): return self._state class Lookup: __implements__ = IPostalLookup _data = { '22401': ('Fredericksburg', 'Virginia'), '44870': ('Sandusky', 'Ohio'), '90051': ('Los Angeles', 'California'), } def lookup(self, postal_code): data = self._data.get(postal_code) if data: return Info(*data) From jim at zope.com Tue Dec 3 08:28:54 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter3 Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter3 - New directory Message-ID: <200212031328.gB3DSsP08777@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter3 In directory cvs.zope.org:/tmp/cvs-serv8771/Chapter3 Log Message: Directory /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter3 added to the repository === Added directory Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter3 === From jim at zope.com Tue Dec 3 16:33:36 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter3 - services.sxi:1.1 Message-ID: <200212032133.gB3LXaC00485@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter3 In directory cvs.zope.org:/tmp/cvs-serv477 Added Files: services.sxi Log Message: rough draft tutorial on developing services === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter3/services.sxi === From jim at zope.com Tue Dec 3 16:35:42 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2 - forms.sxi:1.1 Message-ID: <200212032135.gB3LZgj01014@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2 In directory cvs.zope.org:/tmp/cvs-serv1005 Added Files: forms.sxi Log Message: rough-draft tutorial on schemas and forms. === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter2/forms.sxi === From jim at zope.com Sun Dec 8 03:39:11 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 - New directory Message-ID: <200212080839.gB88dBR11812@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 In directory cvs.zope.org:/tmp/cvs-serv11804/Step7 Log Message: Directory /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 added to the repository === Added directory Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 === From jim at zope.com Sun Dec 8 03:40:23 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step2 - products.zcml:1.3 Message-ID: <200212080840.gB88eNB12049@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step2 In directory cvs.zope.org:/tmp/cvs-serv12042 Modified Files: products.zcml Log Message: Changed to include use of configure.zcml. === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step2/products.zcml 1.2 => 1.3 === --- Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step2/products.zcml:1.2 Thu Jun 20 18:45:35 2002 +++ Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step2/products.zcml Sun Dec 8 03:40:22 2002 @@ -3,6 +3,6 @@ xmlns:browser='http://namespaces.zope.org/browser' > - + From jim at zope.com Sun Dec 8 03:40:00 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step1 - products.zcml:1.3 Message-ID: <200212080840.gB88e0I11910@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step1 In directory cvs.zope.org:/tmp/cvs-serv11903 Modified Files: products.zcml Log Message: Changed to include use of configure.zcml. === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step1/products.zcml 1.2 => 1.3 === --- Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step1/products.zcml:1.2 Wed May 8 16:34:47 2002 +++ Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step1/products.zcml Sun Dec 8 03:40:00 2002 @@ -5,6 +5,6 @@ xmlns:browser='http://namespaces.zope.org/browser' > - + From jim at zope.com Sun Dec 8 03:40:38 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step3 - products.zcml:1.2 Message-ID: <200212080840.gB88ecJ12073@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step3 In directory cvs.zope.org:/tmp/cvs-serv12066 Modified Files: products.zcml Log Message: Changed to include use of configure.zcml. === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step3/products.zcml 1.1 => 1.2 === --- Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step3/products.zcml:1.1 Wed Feb 13 02:57:52 2002 +++ Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step3/products.zcml Sun Dec 8 03:40:37 2002 @@ -5,6 +5,6 @@ xmlns:browser='http://namespaces.zope.org/browser' > - + From jim at zope.com Sun Dec 8 03:41:54 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6 - ContactAddView.py:1.2 Message-ID: <200212080841.gB88fsx12318@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6 In directory cvs.zope.org:/tmp/cvs-serv12311 Modified Files: ContactAddView.py Log Message: Removed references to IContact. === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6/ContactAddView.py 1.1 => 1.2 === --- Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6/ContactAddView.py:1.1 Thu Jun 20 17:49:28 2002 +++ Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6/ContactAddView.py Sun Dec 8 03:41:54 2002 @@ -1,12 +1,11 @@ from Zope.Publisher.Browser.BrowserView import BrowserView -from IContact import IContact from Zope.App.OFS.Container.IAdding import IAdding from Contact import Contact class ContactAddView(BrowserView): "Provide a user interface for adding a contact" - # Assert that we can only be applied to IContact + # Assert that we can only be applied to IAdding __used_for__ = IAdding # action method From jim at zope.com Sun Dec 8 03:44:32 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 - Contact.py:1.1 ContactAdd.py:1.1 ContactAddView.py:1.1 ContactCityState.py:1.1 ContactEditView.py:1.1 ContactInfoView.py:1.1 IContact.py:1.1 IPostal.py:1.1 __init__.py:1.1 add.pt:1.1 configure.zcml:1.1 contact.gif:1.1 contact_product_uml.txt:1.1 edit.pt:1.1 info.pt:1.1 products.zcml:1.1 stubpostal.py:1.1 Message-ID: <200212080844.gB88iWL13829@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 In directory cvs.zope.org:/tmp/cvs-serv13804 Added Files: Contact.py ContactAdd.py ContactAddView.py ContactCityState.py ContactEditView.py ContactInfoView.py IContact.py IPostal.py __init__.py add.pt configure.zcml contact.gif contact_product_uml.txt edit.pt info.pt products.zcml stubpostal.py Log Message: Added step 7 to include generation of object events === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/Contact.py === import Persistence from IContact import IContact class Contact (Persistence.Persistent): """Personal contact information Contacts keep track of personal data, such as name, email and postal address. All methods are protected. """ __implements__ = IContact def __init__(self, first='', last='', email='', address='', pc=''): self.update(first, last, email, address, pc) def name(self): return "%s %s" % (self._first, self._last) def first(self): return self._first def last(self): return self._last def email(self): return self._email def address(self): return self._address def postal_code(self): return self._pc def update(self, first=None, last=None, email=None, address=None, pc=None): if first is not None: self._first = first if last is not None: self._last = last if email is not None: self._email = email if address is not None: self._address = address if pc is not None: self._pc = pc === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactAdd.py === from Zope.App.OFS.Container.IAdding import IAdding from Contact import Contact from Zope.Event import publish from Zope.Event.ObjectEvent import ObjectCreatedEvent from Interface import Interface class IContactAdd(Interface): """Add context using IAdding objects """ def add(first, last, email, address, pc): """Add a contact initialized from the given arguments """ class ContactAdd: "Provide a user interface for adding a contact" # Assert that we can only be applied to IAdding __used_for__ = IAdding __implements__ = IContactAdd def __init__(self, context): self.context = context def add(self, first, last, email, address, pc): contact = Contact() publish(self.context.context, ObjectCreatedEvent(contact)) contact.update(first, last, email, address, pc) self.context.add(contact) === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactAddView.py === from Zope.Publisher.Browser.BrowserView import BrowserView from Zope.App.OFS.Container.IAdding import IAdding from Zope.ComponentArchitecture import getAdapter from ContactAdd import IContactAdd class ContactAddView(BrowserView): "Provide a user interface for adding a contact" # Assert that we can only be applied to IAdding __used_for__ = IAdding # action method def action(self, first, last, email, address, pc): "Add a contact" getAdapter(self.context, IContactAdd).add( first, last, email, address, pc) self.request.response.redirect(self.context.nextURL()) === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactCityState.py === from IPostal import IPostalLookup, IPostalInfo from IContact import IContactInfo from Zope.ComponentArchitecture import getUtility class ContactCityState: "Provide access to city and state information for a contact" __implements__ = IPostalInfo __used_for__ = IContactInfo def __init__(self, contact): self._contact = contact lookup = getUtility(contact, IPostalLookup) info = lookup.lookup(contact.postal_code()) if info is None: self._city, self._state = '', '' else: self._city, self._state = info.city(), info.state() def city(self): return self._city def state(self): return self._state === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactEditView.py === from Zope.Publisher.Browser.BrowserView import BrowserView from IContact import IContact from Zope.Event import publish from Zope.Event.ObjectEvent import ObjectModifiedEvent class ContactEditView(BrowserView): "Provide a user interface for editing a contact" # Assert that we can only be applied to IContact __used_for__ = IContact # action method def action(self, first, last, email, address, pc): "Edit a contact" self.context.update(first, last, email, address, pc) publish(self.context, ObjectModifiedEvent(self.context)) self.request.response.redirect('.') === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactInfoView.py === from Zope.ComponentArchitecture import getAdapter from IContact import IContactInfo from IPostal import IPostalInfo class ContactInfoView: """Provide an interface for viewing a contact """ __used_for__ = IContactInfo def __init__(self, context, request): self.context = context self.request = request self.info = getAdapter(context, IPostalInfo) def city(self): return self.info.city() def state(self): return self.info.state() === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/IContact.py === from Interface import Interface class IContactInfo(Interface): "Provides access to basic contact information." def first(): "Get the first name" def last(): "Get the last name" def email(): "Get the electronic mail address" def address(): "Get the postal address" def postal_code(): "Get the postal code" def name(): """Gets the contact name. The contact name is the first and last name""" class IContact(IContactInfo): "Provides the ability to change contact information." def update(first, last, email, address, pc): """Modifies contact data 'None' values are ignored. """ === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/IPostal.py === from Interface import Interface class IPostalInfo(Interface): "Provide information for postal codes" def city(): """Return the city associated with the postal code. An empty string is returned if the city is unknown. """ def state(): """Return the state associated with the postal code. An empty string is returned if the state is unknown. """ class IPostalLookup(Interface): "Provide postal code lookup" def lookup(postal_code): """Lookup information for a postal code. An IPostalInfo is returned if the postal code is known. None is returned otherwise. """ === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/__init__.py === === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/add.pt === Edit contact
Enter the information about the contact.
First name
Last name
Email
Address
Postal Code
=== Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/configure.zcml === === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/contact.gif === === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/contact_product_uml.txt === <> ---------- | Lookup | ---------- | o IPostalLookup o IPostalInfo ^ | : <> : -------------------- : | ContactCityState |- - - - + -------------------- : : : : <> v IContactInfo ------------------- o<- - - - - - - - - - - - - - - - - - -| ContactInfoView | ^ --------^---------- : V : | : | <> : <> ----------- : ----------- | info.pt | : | edit.pt | ----------- : ----------- : | : ^ <> : IContact --------V---------- o<- - - - - - -| ContactEditView | | ------------------- | ----------- | Contact | ----------- Key: o Interface (catalysis style) ^ V Aggregation <- - - + Dependency : o<- - -o Interface B specializes interface A A B <> Stereotype -------- | name | Class -------- === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/edit.pt === Edit contact
Enter the information about the contact.
First name
Last name
Email
Address
Postal Code
=== Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/info.pt === Contact Information
Contact information
Name: First Last
Address: Mailing address here
Email: foo@bar.com
City: City
State: State
=== Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/products.zcml === === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/stubpostal.py === # Stub postal utility implemantation from IPostal import IPostalLookup, IPostalInfo class Info: __implements__ = IPostalInfo def __init__(self, city, state): self._city, self._state = city, state def city(self): return self._city def state(self): return self._state class Lookup: __implements__ = IPostalLookup _data = { '22401': ('Fredericksburg', 'Virginia'), '44870': ('Sandusky', 'Ohio'), '90051': ('Los Angeles', 'California'), } def lookup(self, postal_code): data = self._data.get(postal_code) if data: return Info(*data) From jim at zope.com Sun Dec 8 03:47:32 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6 - configure.zcml:1.2 Message-ID: <200212080847.gB88lWb14437@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6 In directory cvs.zope.org:/tmp/cvs-serv14430 Modified Files: configure.zcml Log Message: removed title attribute from factory. === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6/configure.zcml 1.1 => 1.2 === --- Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6/configure.zcml:1.1 Thu Jun 20 17:49:28 2002 +++ Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step6/configure.zcml Sun Dec 8 03:47:32 2002 @@ -9,8 +9,7 @@ + permission="ZopeProducts.Contact.ManageContacts" /> From jim at zope.com Sun Dec 8 03:48:33 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:36 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1 - slides.sxi:1.15 Message-ID: <200212080848.gB88mXg14702@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1 In directory cvs.zope.org:/tmp/cvs-serv14476 Modified Files: slides.sxi Log Message: Added step 7 covering Dublin core, annotations, and events. A number of minor fixes. === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/slides.sxi 1.14 => 1.15 === From jim at zope.com Tue Dec 31 15:17:53 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:37 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 - browser.py:1.1 contact.py:1.1 interfaces.py:1.1 configure.zcml:1.2 stubpostal.py:1.2 Contact.py:NONE ContactAdd.py:NONE ContactAddView.py:NONE ContactCityState.py:NONE ContactEditView.py:NONE ContactInfoView.py:NONE IContact.py:NONE IPostal.py:NONE Message-ID: <200212312017.gBVKHr202575@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7 In directory cvs.zope.org:/tmp/cvs-serv2546 Modified Files: configure.zcml stubpostal.py Added Files: browser.py contact.py interfaces.py Removed Files: Contact.py ContactAdd.py ContactAddView.py ContactCityState.py ContactEditView.py ContactInfoView.py IContact.py IPostal.py Log Message: Updated to work with alpha 1 === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/browser.py === from zope.component import getAdapter from zope.app.event import publish from zope.app.event.objectevent import ObjectModifiedEvent from zope.app.interfaces.container import IAdding from interfaces import IContactInfo, IContact, IContactAdd, IPostalInfo class ContactInfoView: """Provide an interface for viewing a contact """ __used_for__ = IContactInfo def __init__(self, context, request): self.context = context self.request = request self.info = getAdapter(context, IPostalInfo) def city(self): return self.info.city() def state(self): return self.info.state() class ContactEditView: "Provide a user interface for editing a contact" # Assert that we can only be applied to IContact __used_for__ = IContact # action method def action(self, first, last, email, address, pc): "Edit a contact" self.context.update(first, last, email, address, pc) publish(self.context, ObjectModifiedEvent(self.context)) self.request.response.redirect('.') class ContactAddView: "Provide a user interface for adding a contact" # Assert that we can only be applied to IAdding __used_for__ = IAdding # action method def action(self, first, last, email, address, pc): "Add a contact" getAdapter(self.context, IContactAdd).add( first, last, email, address, pc) self.request.response.redirect(self.context.nextURL()) === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/contact.py === import persistence from interfaces import IContact, IContactInfo, IContactAdd from interfaces import IPostalLookup, IPostalInfo from zope.app.interfaces.container import IAdding from zope.app.event import publish from zope.app.event.objectevent import ObjectCreatedEvent from zope.component import getUtility class Contact (persistence.Persistent): """Personal contact information Contacts keep track of personal data, such as name, email and postal address. All methods are protected. """ __implements__ = IContact def __init__(self, first='', last='', email='', address='', pc=''): self.update(first, last, email, address, pc) def name(self): return "%s %s" % (self._first, self._last) def first(self): return self._first def last(self): return self._last def email(self): return self._email def address(self): return self._address def postal_code(self): return self._pc def update(self, first=None, last=None, email=None, address=None, pc=None): if first is not None: self._first = first if last is not None: self._last = last if email is not None: self._email = email if address is not None: self._address = address if pc is not None: self._pc = pc class ContactAdd: "Provide a user interface for adding a contact" # Assert that we can only be applied to IAdding __used_for__ = IAdding __implements__ = IContactAdd def __init__(self, context): self.context = context def add(self, first, last, email, address, pc): contact = Contact() publish(self.context.context, ObjectCreatedEvent(contact)) contact.update(first, last, email, address, pc) self.context.add(contact) class ContactCityState: "Provide access to city and state information for a contact" __implements__ = IPostalInfo __used_for__ = IContactInfo def __init__(self, contact): self._contact = contact lookup = getUtility(contact, IPostalLookup) info = lookup.lookup(contact.postal_code()) if info is None: self._city, self._state = '', '' else: self._city, self._state = info.city(), info.state() def city(self): return self._city def state(self): return self._state === Added File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/interfaces.py === from zope.interface import Interface class IContactInfo(Interface): "Provides access to basic contact information." def first(): "Get the first name" def last(): "Get the last name" def email(): "Get the electronic mail address" def address(): "Get the postal address" def postal_code(): "Get the postal code" def name(): """Gets the contact name. The contact name is the first and last name""" class IContact(IContactInfo): "Provides the ability to change contact information." def update(first, last, email, address, pc): """Modifies contact data 'None' values are ignored. """ class IContactAdd(Interface): """Add context using IAdding objects """ def add(first, last, email, address, pc): """Add a contact initialized from the given arguments """ class IPostalInfo(Interface): "Provide information for postal codes" def city(): """Return the city associated with the postal code. An empty string is returned if the city is unknown. """ def state(): """Return the state associated with the postal code. An empty string is returned if the state is unknown. """ class IPostalLookup(Interface): "Provide postal code lookup" def lookup(postal_code): """Lookup information for a postal code. An IPostalInfo is returned if the postal code is known. None is returned otherwise. """ === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/configure.zcml 1.1 => 1.2 === --- Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/configure.zcml:1.1 Sun Dec 8 03:44:31 2002 +++ Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/configure.zcml Tue Dec 31 15:17:52 2002 @@ -3,80 +3,83 @@ xmlns:browser='http://namespaces.zope.org/browser'> - - + + + id="zopeproducts.contact" + permission="zopeproducts.contact.ManageContacts" /> + permission="zope.View" + interface=".interfaces.IContactInfo" /> - - - + - + - + - - - + menu="zmi_views" title="View" + class=".browser.ContactInfoView" + permission="zope.View" + /> - + + + - + - - - - - - + - + + provides=".interfaces.IPostalLookup" + permission="zope.Public" + /> + factory=".contact.ContactCityState" + provides=".interfaces.IPostalInfo" + for=".interfaces.IContactInfo" + permission="zope.Public" + /> === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/stubpostal.py 1.1 => 1.2 === --- Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/stubpostal.py:1.1 Sun Dec 8 03:44:31 2002 +++ Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/stubpostal.py Tue Dec 31 15:17:52 2002 @@ -1,5 +1,5 @@ # Stub postal utility implemantation -from IPostal import IPostalLookup, IPostalInfo +from interfaces import IPostalLookup, IPostalInfo class Info: === Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/Contact.py === === Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactAdd.py === === Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactAddView.py === === Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactCityState.py === === Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactEditView.py === === Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/ContactInfoView.py === === Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/IContact.py === === Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step7/IPostal.py === From jim at zope.com Tue Dec 31 19:28:07 2002 From: jim at zope.com (Jim Fulton) Date: Sun Aug 10 16:40:37 2008 Subject: [Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1 - slides.sxi:1.16 Message-ID: <200301010028.h010S7Q09193@cvs.baymountain.com> Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1 In directory cvs.zope.org:/tmp/cvs-serv9180 Modified Files: slides.sxi Log Message: Updated to be compatable with alpha 1 === Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/slides.sxi 1.15 => 1.16 ===