[Checkins] SVN: bluebream/website/docs/v1.0/tutorial2.rst working example

Baiju M baiju.m.mail at gmail.com
Sun Mar 7 22:11:50 EST 2010


Log message for revision 109792:
  working example
  

Changed:
  U   bluebream/website/docs/v1.0/tutorial2.rst

-=-
Modified: bluebream/website/docs/v1.0/tutorial2.rst
===================================================================
--- bluebream/website/docs/v1.0/tutorial2.rst	2010-03-08 03:11:18 UTC (rev 109791)
+++ bluebream/website/docs/v1.0/tutorial2.rst	2010-03-08 03:11:49 UTC (rev 109792)
@@ -45,6 +45,11 @@
   object inside other container objects.  Ticket objects will be
   transformed to a container object.
 
+.. note::
+
+   The examples in this documentation can be downloaded from here:
+   http://download.zope.org/bluebream/examples/ticketcollector-1.0.0.tar.bz2
+
 .. _tut2-adding-tickets:
 
 Adding tickets
@@ -58,12 +63,14 @@
 for tickets.  Update the ``src/tc/main/interfaces.py`` with the ticket
 interface::
 
+  from zope.interface import Interface
+
   class ITicket(Interface):
-     """Ticket - the main content component"""
+      """Ticket - the ticket content component"""
 
-      name = TextLine(
-          title=u"Name",
-          description=u"Name of application.",
+      number = TextLine(
+          title=u"Number",
+          description=u"Ticket number",
           default=u"",
           required=True)
 
@@ -73,10 +80,10 @@
           default=u"",
           required=True)
 
-The ``Interface``, ``TextLine`` and ``Text`` are already imported, if
-not, you can import it from these locations::
 
-  from zope.container.interfaces import IContainer
+The ``TextLine`` and ``Text`` are already imported, if not, you can
+import it from these locations::
+
   from zope.schema import TextLine
   from zope.schema import Text
 
@@ -90,10 +97,11 @@
 attribute, which is an instance of ``ItemTypePrecondition`` class.
 You can pass the interfaces as arguments to ``ItemTypePrecondition``
 class.  Below, only one class (``ITicket``) is passed.  So, only
-ticket objects are allowed inside collector.
+ticket objects are allowed inside collector.  You need to move the
+definition of ``ITicket`` above the ``IContainer`` as the ``ITicket``
+being used there.  Add the following method definition to
+``ICollector`` class::
 
-::
-
     from zope.app.container.constraints import ItemTypePrecondition
 
     def __setitem__(name, object):
@@ -131,7 +139,7 @@
   from zope.interface import implements
   from tc.main.interfaces import ITicket
   from tc.main.interfaces import ITicketContained
-  from zope.location.contained import Contained
+  from zope.container.contained import Contained
 
 
   class Ticket(Contained):
@@ -146,22 +154,22 @@
 
 Then, register the interface & class::
 
-  <interface 
-     interface=".interfaces.ITicket" 
+  <interface
+     interface="tc.main.interfaces.ITicket"
      type="zope.app.content.interfaces.IContentType"
-     /> 
+     />
 
-  <class class=".ticket.Ticket">
+  <class class="tc.main.ticket.Ticket">
     <implements
        interface="zope.annotation.interfaces.IAttributeAnnotatable"
        />
     <require
        permission="zope.ManageContent"
-       interface=".interfaces.ITicket"
+       interface="tc.main.interfaces.ITicket"
        />
     <require
        permission="zope.ManageContent"
-       set_schema=".interfaces.ITicket"
+       set_schema="tc.main.interfaces.ITicket"
        />
   </class>
 
@@ -189,12 +197,12 @@
 
 You can register the view inside `configure.zcml`::
 
-    <browser:page
-       for=".interfaces.ICollector"
-       name="add_ticket"
-       permission="zope.ManageContent"
-       class=".views.AddTicket"
-       />
+  <browser:page
+     for="tc.main.interfaces.ICollector"
+     name="add_ticket"
+     permission="zope.ManageContent"
+     class="tc.main.views.AddTicket"
+     />
 
 Adding Comments
 ---------------
@@ -233,10 +241,10 @@
 
 Then, register the interface & class::
 
-  <interface 
-     interface=".interfaces.IComment" 
+  <interface
+     interface=".interfaces.IComment"
      type="zope.app.content.interfaces.IContentType"
-     /> 
+     />
 
   <class class=".ticket.Comment">
     <implements



More information about the checkins mailing list