[Zope-book] CVS: Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5 - Contact.py:1.2.2.1 Contact.zcml:1.7.2.1 ContactEditView.py:1.1.2.1 IContact.py:1.2.2.1 IContactEdit.py:1.1.2.1 IContactInfo.py:1.1.2.1 __init__.py:1.3.2.1 edit.pt:1.5.2.1 stubpostal.py:1.5.2.1 ContactInfoView.py:NONE ContactViewPresentation.py:NONE

Jim Fulton jim at zope.com
Tue Jun 4 16:05:49 EDT 2002


Update of /cvs-repository/Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5
In directory cvs.zope.org:/tmp/cvs-serv29193

Modified Files:
      Tag: Zope3InWonderland-branch
	Contact.py Contact.zcml ContactEditView.py IContact.py 
	IContactEdit.py IContactInfo.py __init__.py edit.pt 
	stubpostal.py 
Removed Files:
      Tag: Zope3InWonderland-branch
	ContactInfoView.py ContactViewPresentation.py 
Log Message:
Contact step 5 now works with the Zope3InWonderland-branch! (and the Zope3InWonderland-branch works with it ;)

=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/Contact.py 1.2 => 1.2.2.1 ===
 import Persistence
+from IContact import IContact
 
 class Contact (Persistence.Persistent):
-    """Contacts keep track of personal data, such as name, email
-    and postal address.  All methods are protected."""
+    """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)


=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/Contact.zcml 1.7 => 1.7.2.1 ===
 
 <security:permission
-   permission_id=".Contact.ManageContacts" 
+   id="ZopeProducts.Contact.ManageContacts" 
    title="Manage Contacts" />
 
-<security:protectClass name=".Contact.">
-  <security:protect interface=".Contact.IContactInfo."  
-                    permission_id="Zope.View" />
-  <security:instances permission_id="Zope.View"/>
-  <security:protect methods="update"
-                    permission_id=".Contact.ManageContacts"/>
-</security:protectClass>
-
-<security:protectClass name=".Contact.ContactInfoView."
-                       permission_id="Zope.View" />
-
-<security:protectClass name=".Contact.ContactEditView."
-                       permission_id=".Contact.ManageContacts"
-                       methods="index, action" />
-
-<zmi:factoryFromClass name=".Contact." 
-                  permission_id=".Contact.ManageContacts"
-                  title="Personal Contact Information" />
-
-<browser:defaultView for=".Contact.IContactInfo."
-                     name="info"
-                     factory=".Contact.ContactInfoView." />
-
-<browser:view for=".Contact.IContactEdit."
-              name="edit"
-              factory=".Contact.ContactEditView." />
-
-<zmi:tabs for=".Contact.IContact.">
-  <zmi:tab label="Edit"     action="edit;view"/>
-  <zmi:tab label="View"     action="info;view"/>
+<content class=".Contact.">
+
+  <zmi:factory
+    permission="ZopeProducts.Contact.ManageContacts"
+    title="Personal Contact Information" />
+
+  <security:require permission="Zope.View"
+                    interface=".IContact.IContactInfo." />
+
+  <security:require permission="ZopeProducts.Contact.ManageContacts"
+                    attributes="update"/>
+
+</content>
+
+<browser:defaultView for=".IContact.IContactInfo."
+                     name="info.html" />
+
+<browser:view for=".IContact.IContactInfo."
+              name="info.html" 
+              template="info.pt"
+              permission="Zope.View" />
+
+<browser:view for=".IContact."
+              factory=".ContactEditView."
+              permission="ZopeProducts.Contact.ManageContacts" >
+
+   <browser:page name="editForm.html" attribute="editForm" />
+   <browser:page name="edit.html"     attribute="edit" />
+
+</browser:view>
+
+<zmi:tabs for=".IContact.">
+  <zmi:tab label="Edit"     action="editForm.html"/>
+  <zmi:tab label="View"     action="info.html"/>
+  <!-- zmi:tab label="Undo"     action="undo"/  -->
 </zmi:tabs>
 
-<zmi:icon for=".Contact.IContact." file="Contact/contact.gif" />
+<zmi:icon for=".IContact." file="Contact/contact.gif" />
 
-<security:protectClass 
-    name=".Contact.stubpostal.Lookup"
-    interface=".Contact.IPostal.IPostalLookup."
-    permission_id="Zope.Public"  />
-
-<security:protectClass
-    name=".Contact.stubpostal.Info"
-    interface=".Contact.IPostal.IPostalInfo" 
-    permission_id="Zope.Public" />
+<content class=".stubpostal.Info">
+  <security:allow interface=".IPostal.IPostalInfo" />
+</content>
 
 <utility
-    component=".Contact.stubpostal.lookup" 
-    provides=".Contact.IPostal.IPostalLookup" />
-
-<security:protectClass name=".Contact.ContactCityState."
-  interface=".Contact.IPostal.IPostalInfo"
-  permission_id="Zope.Public"  />
+    factory=".stubpostal.Lookup" 
+    provides=".IPostal.IPostalLookup"
+    permission="Zope.Public" />
 
 <adapter
-  factory=".Contact.ContactCityState."
-  provides=".Contact.IPostal.IPostalInfo" 
-  for=".Contact.IContactInfo." />
-
+  factory=".ContactCityState."
+  provides=".IPostal.IPostalInfo" 
+  for=".IContact.IContactInfo"
+  permission="Zope.Public"
+  />
 
 </zopeConfigure>


=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/ContactEditView.py 1.1 => 1.1.2.1 ===
-from Zope.PageTemplate import PageTemplateFile
-from IContactEdit import IContactEdit
-
-class ContactEditView(AttributePublisher):
-    """Provide an interface for editing a contact
-    """
-
-    # Boiler plate
-    def __init__(self, context):
-        self._context=context
-
-    def getContext(self):
-        return self._context
-
-    # Assert that we can only be applied to IContactEdit
-    __used_for__=IContactEdit
+from Zope.App.PageTemplate import ViewPageTemplateFile
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from IContact import IContact
+
+class ContactEditView(BrowserView):
+    "Provide a user interface for editing a contact"
+    
+    # Assert that we can only be applied to IContact
+    __used_for__ = IContact
 
     # Input form
-    index = PageTemplateFile('edit.pt', globals())
+    editForm = ViewPageTemplateFile('edit.pt')
 
     # action method
-    def action(self, first, last, email, address, pc, REQUEST):
+    def edit(self, first, last, email, address, pc):
         "Edit a contact"
-        self.getContext().update(first, last, email, address, pc)
-        return self.index(REQUEST)
+        self.context.update(first, last, email, address, pc)
+        return self.editForm()


=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/IContact.py 1.2 => 1.2.2.1 ===
+from Interface import Interface
 
-# Local Package imports
-from Contact import Contact
+class IContactInfo(Interface):
+    "Provides access to basic contact information."
 
-class IContact(Interface):
-    "Marker for objects that provide specific behavior"
+    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"
 
-implements(Contact, IContact)
+    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.
+        """


=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/IContactEdit.py 1.1 => 1.1.2.1 ===
 from Contact import Contact
-from Interface import implements
+from Interface.Implements import implements
 
 class IContactEdit(IContactInfo):
     "Provides the ability to change basic contact information."


=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/IContactInfo.py 1.1 => 1.1.2.1 ===
+from Interface import Interface
+from Interface.Implements import implements
 
 # Local Package imports
 from Contact import Contact


=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/__init__.py 1.3 => 1.3.2.1 ===


=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/edit.pt 1.5 => 1.5.2.1 ===
 <div metal:fill-slot="body">
 Enter the information about the contact.
-<form action="action.html" method="post">
+<form action="edit.html" method="post">
 <table cellspacing="0" cellpadding="2" border="0">
   <tr><td> First name</td>
       <td><input type="text" name="first" size="40" value=""


=== Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/stubpostal.py 1.5 => 1.5.2.1 ===
         if data is not None: data = Info(*data)
         return data
-
-lookup=Lookup()

=== Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/ContactInfoView.py ===

=== Removed File Docs/ZopeComponentArchitecture/PythonProgrammerTutorial/Chapter1/Step5/ContactViewPresentation.py ===






More information about the Zope-book mailing list