[Commits] (twl) Fix bug 2113 - update repository overview for 0.4

commits at osafoundation.org commits at osafoundation.org
Tue Oct 12 13:06:13 PDT 2004


Commit by: twl
Modified files:
chandler/distrib/docs/repository-intro.html 1.8 1.9

Log message:
Fix bug 2113 - update repository overview for 0.4


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/distrib/docs/repository-intro.html.diff?r1=text&tr1=1.8&r2=text&tr2=1.9

Index: chandler/distrib/docs/repository-intro.html
diff -u chandler/distrib/docs/repository-intro.html:1.8 chandler/distrib/docs/repository-intro.html:1.9
--- chandler/distrib/docs/repository-intro.html:1.8	Fri Feb 27 17:00:13 2004
+++ chandler/distrib/docs/repository-intro.html	Tue Oct 12 13:06:12 2004
@@ -8,7 +8,7 @@
 
 <center>
 <h1>The Busy Developer's Guide to the Chandler repository</h1>
-Version 0.1
+Version 0.4
 </center>
 
 <p> This document is an introduction to the features of the Chandler
@@ -68,52 +68,65 @@
 
 <h3>Defining Schema</h3>
 
-<p>Let's look at a simple parcel from the repository unit tests, <span class="file">Chandler/repository/parcel/tests/testparcels/simple/parcel.xml</span>:</p>
-
+<p>Let's look at a simple parcel from the repository unit tests, <span class="file">chandler/application/tests/testparcels/simple/parcel.xml</span>:</p>
 <pre>
-    &lt;xml version="1.0" encoding="iso-8859-1"?&gt;
-
-    &lt;Parcel itemName="simple"
-        xmlns="//Schema/Core"
-        xmlns:simple="//parcels/simple"&gt;
-
-        &lt;displayName&gt;Simple&lt;/displayName&gt;
-        &lt;description&gt;Simple Parcel Loader Test Schema&lt;/description&gt;
-        &lt;version&gt;0.1&lt;/version&gt;
-        &lt;author&gt;Open Source Applications Foundation&lt;/author&gt;
-
-        &lt;Kind itemName="TestKind"&gt;
-            &lt;displayName&gt;Test Kind&lt;/displayName&gt;
-            &lt;attributes itemref="simple:TestAttribute"/&gt;
-            &lt;displayAttribute itemref="simple:TestAttribute"/&gt;
-        &lt;/Kind&gt;
-
-        &lt;Kind itemName="SubKind"&gt;
-            &lt;superKinds itemref="simple:TestKind"/&gt;
-            &lt;displayName&gt;Subclass of Test Kind&lt;/displayName&gt;
-        &lt;/Kind&gt;
-
-        &lt;Attribute itemName="TestAttribute"&gt;
-            &lt;displayName&gt;Test Attribute&lt;/displayName&gt;
-            &lt;cardinality&gt;single&lt;/cardinality&gt;
-            &lt;type itemref="String"/&gt;
-        &lt;/Attribute&gt;
+&lt;Parcel itsName="simple"
+        xmlns="http://osafoundation.org/parcels/core"
+        xmlns:simple="http://testparcels.org/simple" &gt;
+
+  &lt;namespace value="http://testparcels.org/simple" /&gt;
+
+  &lt;displayName value="Simple Parcel" /&gt;
+  &lt;description value="Simple Parcel Loader Test Schema" /&gt;
+  &lt;version value="0.1" /&gt;
+  &lt;author value="Open Source Applications Foundation" /&gt;
+
+  &lt;Kind itsName="TestKind"&gt;
+    &lt;displayName value="Test Kind" /&gt;
+    &lt;attributes itemref="simple:TestAttribute"/&gt;
+    &lt;attributes itemref="simple:ListAttribute"/&gt;
+    &lt;attributes itemref="simple:DictAttribute"/&gt;
+    &lt;displayAttribute itemref="simple:TestAttribute"/&gt;
+  &lt;/Kind&gt;
+
+  &lt;Kind itsName="SubKind"&gt;
+    &lt;superKinds itemref="simple:TestKind"/&gt;
+    &lt;displayName value="Subclass Test Kind" /&gt;
+  &lt;/Kind&gt;
+
+  &lt;Attribute itsName="TestAttribute"&gt;
+    &lt;displayName value="Test Attribute" /&gt;
+    &lt;cardinality value="single" /&gt;
+    &lt;type itemref="String"/&gt;
+    &lt;initialValue type="String" value="XYZZY" /&gt;
+  &lt;/Attribute&gt;
+
+  &lt;Attribute itsName="ListAttribute"&gt;
+    &lt;displayName value="List Attribute" /&gt;
+    &lt;cardinality value="list" /&gt;
+    &lt;type itemref="String"/&gt;
+    &lt;initialValue/&gt;
+  &lt;/Attribute&gt;
+
+  &lt;Attribute itsName="DictAttribute"&gt;
+    &lt;displayName value="Dict Attribute" /&gt;
+    &lt;cardinality value="dict" /&gt;
+    &lt;type itemref="String"/&gt;
+    &lt;initialValue/&gt;
+  &lt;/Attribute&gt;
 
-    &lt;/Parcel&gt;
+&lt;/Parcel&gt;
 </pre>
 
 As the parcel loader parses the XML, whenever it sees an element with
-the <span class="code">itemName</span> attribute it creates an item in the repository.
+the <span class="code">itsName</span> attribute it creates an item in the repository.
 For a parcel file, the outermost element should be Parcel. When defining
 kinds and attributes, use elements of Kind and Attribute.  Remember that
-all elements of these types must be in the XML namespace //Schema/Core.
-<i>Note:  we're currently overloading the meaning of our namespaces to
-use them as repository paths; this syntax is likely to change in the
-future.</i> The nesting arrangement of the items in a parcel file will
+all elements of these types must be in the XML namespace http://osafoundation.org/parcels/core.  The nesting arrangement of the items in a parcel file will
 be duplicated in the repository hierarchy.  </p>
 
 <p> First the <span class="code">&lt;Parcel&gt;</span> element:  its
-<span class="code">itemName</span> attribute is used to name the item in the repository.
+<span class="code">itsName</span> attribute is used to name the item in the repository.
 By convention a parcel item's name needs to match the directory in which the
 parcel.xml file resides (in this case, "simple").  The parcel loader will
 create an item of kind "//Schema/Core/Parcel" in the repository, with a path
@@ -121,10 +134,10 @@
 </p>
 
 <p>When the parcel loader encounters an element that does not have
-an <span class="code">itemName</span>, the element is instead used to assign a
+an <span class="code">itsName</span>, the element is instead used to assign a
 value to one of the parent element's attributes.  In the example, the
 parcel's <span class="code">displayName</span> attribute is assigned the literal
-"Simple".  Another type of assignment is a reference; if an element
+"Simple Parcel".  Another type of assignment is a reference; if an element
 has an <span class="code">itemref</span>, then instead of a literal assignment, a
 reference to the specified item is assigned.  For example, within the
 "TestKind" item, a reference to the "TestAttribute" item (also defined
@@ -132,17 +145,19 @@
 
 <p>The result of parsing this file will be:
 <ul>
-<li>A parcel item at <span class="path">//parcels/simple</span> (with displayName="Simple")
-<li>A kind item at <span class="path">//parcels/simple/TestKind</span> (with displayName = "Test Kind", attributes = <span class="path">//parcels/simple/TestAttribute</span>, and displayAttribute = <span class="path">//parcels/simple/TestAttribute</span>)
+<li>A parcel item at <span class="path">//parcels/simple</span> (with displayName="Simple Parcel")
+<li>A kind item at <span class="path">//parcels/simple/TestKind</span> (with displayName = "Test Kind", attributes = [<span class="path">//parcels/simple/TestAttribute</span>, <span class="path">//parcels/simple/ListAttribute</span>, <span class="path">//parcels/simple/DictAttribute</span> ], and displayAttribute = <span class="path">//parcels/simple/TestAttribute</span>)
 <li>A kind item at <span class="path">//parcels/simple/SubKind</span> (with displayName = "Subclass of Test Kind", superKinds = <span class="path">//parcels/simple/TestKind</span>
 <li>An attribute item at <span class="path">//parcels/simple/TestAttribute</span> (with displayName = "Test Attribute", cardinality = "single", and type = <span class="path">//Schema/Core/String</span>)
+<li>An attribute item at <span class="path">//parcels/simple/ListAttribute</span> (with displayName = "List Attribute", cardinality = "list", and type = <span class="path">//Schema/Core/String</span>)
+<li>An attribute item at <span class="path">//parcels/simple/DictAttribute</span> (with displayName = "Dict Attribute", cardinality = "dict", and type = <span class="path">//Schema/Core/String</span>)
 </ul>
 </p>
 
 <p>So what does this mean in terms of the data model? 
 <ol>
 <li>Our simple schema has defined two kinds (TestKind and SubKind) and an attribute (TestAttribute)
-<li>We have declared that instances of TestKind (items whose kind is TestKind) have an attribute named "TestAttribute" (by assigning to the "attributes" attribute)
+<li>We have declared that instances of TestKind (items whose kind is TestKind) have 3 attributes named "TestAttribute", "ListAttribute", and "DictAttribute" (by assigning to the "attributes" attribute)
 <li>We have declared that SubKind is a "subclass" of TestKind (by assigning to the "superKinds" attribute).  SubKind will inherit the characteristics of
 TestKind, including the list of allowed attributes.
 </ol>
@@ -154,31 +169,32 @@
 the 0.3 release, you need to put your data (non schema) items in a
 separate parcel file from your schema, so we've put this in
 <span class="file">Chandler/repository/parcel/tests/testparcels/simple/data/parcel.xml</span>: </p>
-
 <pre>
-    &lt;xml version="1.0" encoding="iso-8859-1"?&gt;
+&lt;Parcel itsName="data"
+        xmlns="http://osafoundation.org/parcels/core"
+        xmlns:simple="http://testparcels.org/simple" &gt;
 
-    &lt;Parcel itemName="data"
-            xmlns="//Schema/Core"
-            xmlns:simple="//parcels/simple"&gt;
+  &lt;namespace value="http://testparcels.org/simple/data" /&gt;
 
-      &lt;simple:TestKind itemName="item1"&gt;
-          &lt;TestAttribute&gt;xyzzy&lt;/TestAttribute&gt;
-      &lt;/simple:TestKind&gt;
+  &lt;simple:TestKind itsName="item1"&gt;
+    &lt;TestAttribute&gt;xyzzy&lt;/TestAttribute&gt;
+  &lt;/simple:TestKind&gt;
 
-      &lt;simple:SubKind itemName="item2"&gt;
-          &lt;TestAttribute&gt;plugh&lt;/TestAttribute&gt;
-      &lt;/simple:SubKind&gt;
+  &lt;simple:SubKind itsName="item2"&gt;
+    &lt;TestAttribute&gt;plugh&lt;/TestAttribute&gt;
+  &lt;/simple:SubKind&gt;
 
-    &lt;/Parcel&gt;
-</pre>
+  &lt;simple:TestKind itsName="item3"/&gt;
 
+&lt;/Parcel&gt;
+</pre>
 <p>
 When this parcel is loaded, three new items will be added to the repository:
 <ul>
 <li>A parcel item at <span class="path">//parcels/simple/data</span>
 <li>A TestKind item at <span class="path">//parcels/simple/data/item1</span> (with TestAttribute="xyzzy")
 <li>A SubKind item at <span class="path">//parcels/simple/data/item2</span> (with TestAttribute="plugh")
+<li>A TestKind item at <span class="path">//parcels/simple/data/item3</span> 
 </ul>
 </p>
 
@@ -196,16 +212,16 @@
 
 The first thing that we are going to need is a repository object that
 we can work with.  When you are working within Chandler, there is an
-application global, application.Globals.repository that is the
+application global, <span class="code">application.Globals.repository</span> whose value is the
 repository that the current Chandler instance is using.  I'm going to
 show you how to obtain a repository object from scratch.  
 <p />
-Use the Chandler build tool, <span class="code">hardhat</span>, to run an interactive python session.
+Use the Chandler build tool, <span class="code">hardhat</span>, to run an interactive python session.  You'll want to be in the "chandler" director when you do this.
 <pre>
-> cd osaf/chandler/Chandler
-> ../../hardhat/hardhat.py -i
-Python 2.3.2 (#1, Jan 21 2004, 18:08:56)
-[GCC 3.3.2] on linux2
+> cd osaf/chandler
+> ../hardhat/hardhat.py -i
+Python 2.3.3 (#1, Sep 22 2004, 23:52:03) 
+[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
 Type "help", "copyright", "credits" or "license" for more information.
 >>>
 </pre>
@@ -213,8 +229,7 @@
 <p />
 First we need some modules from Chandler
 <p />
-<pre class="codebox">
-import os
+<pre class="codebox">import os
 from repository.persistence.XMLRepository import XMLRepository
 </pre>
 <p />
@@ -250,6 +265,7 @@
 Normally as part of the Chandler startup process, all parcels in
 osaf/chandler/Chandler/parcels are loaded automatically.  For this interactive session, however, we'll just explicitly load our data parcel instead:</p>
 
+<!--
 <pre class="codebox">
 from repository.parcel.LoadParcels import LoadParcel
 parcelRoot = os.path.join("repository","parcel","tests","testparcels")
@@ -257,83 +273,65 @@
 repoPath = "//parcels/simple/data"
 LoadParcel(parcelToLoad, repoPath, parcelRoot, rep)
 </pre>
+-->
+<pre class="codebox">from application.Parcel import Manager as ParcelManager
 
-<p><span class="code">parcelToLoad</span> is the directory containing our data
-parcel.xml.  <span class="code">repoPath</span> is the path within the repository we
-want to load our parcel. <span class="code">parcelRoot</span> is the directory in which
-the parcel loader will search for parcels that our parcel depends on.  
+manager = ParcelManager.getManager(rep, ['./application/tests/testparcels', './parcels'])
+
+namespaces = ['http://testparcels.org/simple/data']
+manager.loadParcels(namespaces)
+</pre>
+
+<p>The first line imports the packages we need in order to use the Parcel loader.  
+We call the method<span class="code">ParcelManager.getManager</span> in order to get an instance of the Parcel loader.  The first argument, <span class="code">rep</span>, is the repository that we've just created.
+The second argument is a list of directories to search for parcels.  The first element in the list  is the directory containing the parcel.xml file for our data parcel.  The second element is the root of the OSAF supplied parcels.  The list <span class="code">namespaces</span> is a list of namespaces (URI's) for the parcels that you want to load.
 In this case, our data parcel depends on our schema parcel, and so the
-schema will be loaded as well. And of course, rep is the repository we've just created.</p>
+schema will be loaded as well. </p>
 
 <p>To see what's in the repository, we can print out part of its contents
 using <span class="code">PrintItem( )</span>:</p>
 
-<pre class="codebox">from repository.parcel.Util import PrintItem
+<pre class="codebox">from application.Parcel import PrintItem as PrintItem
 PrintItem("//parcels/simple", rep)
 </pre>
 
-<p>You should get something like this, a description of <span class="path">//parcels/simple</span> and
-ll of it's children (recursive):</p>
-
+<p>You should get something like this, a description of <span class="path">//parcels/simple</span> and all of it's children (recursive):</p>
 <pre>
-//parcels/simple
-    displayName: Simple Parcel &lt;type 'unicode'&gt;
-    description: Simple Parcel Loader Test Schema &lt;type 'unicode'&gt;
+//parcels/simple (Kind: //Schema/Core/Parcel)
     author: Open Source Applications Foundation &lt;type 'unicode'&gt;
-    createdOn: 2004-02-02 12:22:26.22 &lt;type 'DateTime'&gt;
+    createdOn: 2004-10-07 17:40:41.01 &lt;type 'DateTime'&gt;
+    description: Simple Parcel Loader Test Schema &lt;type 'unicode'&gt;
+    displayName: Simple Parcel &lt;type 'unicode'&gt;
+    file: ./application/tests/testparcels/simple/parcel.xml &lt;type 'str'&gt;
+    modifiedOn: 2004-10-07 17:40:41.01 &lt;type 'DateTime'&gt;
+    namespace: http://testparcels.org/simple &lt;type 'unicode'&gt;
+    namespaceMap: (dict)
+    originalValues: (dict)
+        : {'namespace': u'http://testparcels.org/simple', 
+           'version': u'0.1', 
+           'displayName': u'Simple Parcel', 
+           'description': u'Simple Parcel Loader Test Schema', 
+           'author': u'Open Source Applications Foundation'}
+        ListAttribute: {'displayName': u'List Attribute', 
+                        'cardinality': u'list', 
+                        'initialValue': '', 
+                        'type': 'ab8c18ea-18c2-11d9-85f4-000a959a114e'}
+        TestAttribute: {'displayName': u'Test Attribute', 
+                        'cardinality': u'single', 
+                        'initialValue': u'XYZZY', 
+                        'type': 'ab8c18ea-18c2-11d9-85f4-000a959a114e'}
+        TestKind: {'attributes': ['ae479b5e-18c2-11d9-85f4-000a959a114e', 
+                                  'ae4b2652-18c2-11d9-85f4-000a959a114e', 
+                                  'ae4c3920-18c2-11d9-85f4-000a959a114e'], 
+                   'displayName': u'Test Kind', 
+                   'displayAttribute': 'ae479b5e-18c2-11d9-85f4-000a959a114e'}
+        SubKind: {'superKinds': ['ae3f7c80-18c2-11d9-85f4-000a959a114e'], 
+                  'displayName': u'Subclass Test Kind'}
+        DictAttribute: {'displayName': u'Dict Attribute', 
+                        'cardinality': u'dict', 
+                        'initialValue': '', 
+                        'type': 'ab8c18ea-18c2-11d9-85f4-000a959a114e'}
     version: 0.1 &lt;type 'unicode'&gt;
-    modifiedOn: 2004-02-02 12:22:26.22 &lt;type 'DateTime'&gt;
-    kind: //Schema/Core/Parcel
-
-  //parcels/simple/TestKind
-      displayName: Test Kind &lt;type 'unicode'&gt;
-      displayAttribute: TestAttribute &lt;type 'unicode'&gt;
-      kind: //Schema/Core/Kind
-      superKinds: (dict)
-          //Schema/Core/Item
-      items: (dict)
-          //parcels/simple/data/item1
-      subKinds: (dict)
-          //parcels/simple/SubKind
-      attributes:
-          //parcels/simple/TestAttribute
-          //Schema/Core/displayName (from //Schema/Core/Item)
-          //Schema/Core/description (from //Schema/Core/Item)
-          //Schema/Core/issues (from //Schema/Core/Item)
-          //Schema/Core/examples (from //Schema/Core/Item)
-          //Schema/Core/Item/kind (from //Schema/Core/Item)
-
-  //parcels/simple/SubKind
-      displayName: Subclass Test Kind &lt;type 'unicode'&gt;
-      superKinds: (dict)
-          //Schema/Core/Item
-          //parcels/simple/TestKind
-      items: (dict)
-          //parcels/simple/data/item2
-      kind: //Schema/Core/Kind
-
-  //parcels/simple/TestAttribute
-      cardinality: single &lt;type 'unicode'&gt;
-      displayName: Test Attribute &lt;type 'unicode'&gt;
-      type: //Schema/Core/String
-      kind: //Schema/Core/Attribute
-      kinds: (dict)
-          //parcels/simple/TestKind
-      inheritingKinds: (dict)
-          //parcels/simple/SubKind
-
-  //parcels/simple/data
-      createdOn: 2004-02-02 12:22:26.27 &lt;type 'DateTime'&gt;
-      modifiedOn: 2004-02-02 12:22:26.27 &lt;type 'DateTime'&gt;
-      kind: //Schema/Core/Parcel
-
-    //parcels/simple/data/item1
-        TestAttribute: xyzzy &lt;type 'unicode'&gt;
-        kind: //parcels/simple/TestKind
-
-    //parcels/simple/data/item2
-        TestAttribute: plugh &lt;type 'unicode'&gt;
-        kind: //parcels/simple/SubKind
 </pre>
 
 <h3>Working with Items</h3>
@@ -344,7 +342,7 @@
 </p>
 
 <pre class="codebox">
-item1 = rep.find("//parcels/simple/data/item1")
+item1 = rep.findPath("//parcels/simple/data/item1")
 </pre>
 
 <p>If you <span class="code">print item1</span></p>
@@ -355,14 +353,14 @@
 &lt;Item: item1 843636cc-55bd-11d8-f385-000a95bb2738&gt;
 </span>
 
-<p>This shows the item's class name (this may change to be the kind), name, and UUID.  Every item in the repository has a unique identifier or UUID.  You can also use the <span class="code">getUUID()</span> method to get an item's UUID.</p>
+<p>This shows the item's class name (this may change to be the kind), name, and UUID.  Every item in the repository has a unique identifier or UUID.  You can  use the <span class="code">itsUUID</span> attribute to get an item's UUID.</p>
 <p />
-<pre class="codebox">uuid = item1.getUUID()
+<pre class="codebox">uuid = item1.itsUUID
 </pre>
 <p />
-The <span class="code">find</span> method can also find by using an Item's UUID.
+You can use the <span class="code">findUUID</span> method to find by using an Item's UUID.
 <p />
-<pre class="codebox">item1 = rep.find(uuid)
+<pre class="codebox">item2 = rep.findUUID(uuid)
 </pre>
 <p />
 Note: at the moment, you should be careful when using UUID's to find
@@ -376,14 +374,14 @@
 <p />
 <table>
 <tr><td>
-<span class="code">Item.getItemName()</span></td>
+<span class="code">Item.itsName</span></td>
 <td>get the name of the item</td></tr>
 <tr><td>
-<span class="code">Item.getItemParent()</span></td>
+<span class="code">Item.itsParent</span></td>
 <td>get the item which is the parent of this item
 </td></tr>
 <tr><td>
-<span class="code">Item.getItemPath()</span></td>
+<span class="code">Item.itsPath</span></td>
 <td>get the path to this item
 </td></tr>
 <tr><td>
@@ -406,17 +404,17 @@
 add a new instance of TestKind.  To do this, we first need to retrieve
 the TestKind item:</p>
 
-<pre class="codebox">testKind = rep.find("//parcels/simple/TestKind")
+<pre class="codebox">testKind = rep.findPath("//parcels/simple/TestKind")
 </pre>
 
 <p>Next we need to fetch the item that will be our new item's parent:</p>
 
-<pre class="codebox">data = rep.find("//parcels/simple/data")
+<pre class="codebox">data = rep.findPath("//parcels/simple/data")
 </pre>
 
 <p>Next we tell the kind to create a new item as a child of data:</p>
 
-<pre class="codebox">item3 = testKind.newItem("item3", data)
+<pre class="codebox">newItem = testKind.newItem("newItem", data)
 </pre>
 <p>
 The first argument to the newItem() method is the name of the item, and the 
@@ -435,20 +433,21 @@
 <p />
 You can test whether or not an item has a child with a particular name
 <p />
-<pre class="codebox">print data.hasChild("item3")
+<pre class="codebox">print data.hasChild("newItem")
 </pre>
 <p />
-You can get a child by providing its name  (2 ways, the first returning <span class="code">None</span>
-if the child is not found, the other raising a <span class="code">KeyError</span> exception instead)
+You can get a child by providing its name  (there are 2 ways shown below, the first returns <span class="code">None</span>
+if the child is not found, the other raises a <span class="code">KeyError</span> exception instead)
 <p />
-<pre class="codebox">print data.getItemChild("item3")
-print data['item3']
+<pre class="codebox">print data.getItemChild("newItem")
+
+print data['newItem']
 </pre>
 <p />
 
 You can rearrange the children of an item by using the <span class="code">placeChild()</span> method.
 <p />
-<pre class="codebox">data.placeChild(data.getItemChild("item3"), None)</pre>
+<pre class="codebox">data.placeChild(data.getItemChild("newItem"), None)</pre>
 <p> will make the 'item3' child the first child of <span class="code">data</span>.
 The first argument is the child you want to move, the second argument
 is the child that you want to place the first child after.
@@ -457,7 +456,7 @@
 <p>
 To change an Item's parent you would use the <span class="code">move()</span> method.  If I wanted to take 'item3' and make it a child of the repository, the code would look like this:
 <p />
-<pre class="codebox">item3.move(rep)
+<pre class="codebox">newItem.move(rep)
 </pre>
 <p />
 The first argument to move is the new root for the item being moved.  You can also specify where the item will be among the new root's children by specifying a 2nd and 3rd argument, which specify the children preceding and following the new item. 
@@ -466,14 +465,14 @@
 <h3>Attributes</h3>
 All of the data in Chandler items is stored as attributes.  Attributes are themselves items, albeit of a special type (the recursion has to stop somewhere).  The API for attributes has been designed to look as much like the Python API for working with attributes.
 
-If we look at the item we created, <span class="code">item3</span> we can set its attribute values using the normal Python syntax:
+If we look at the item we created, <span class="code">newItem</span> we can set its attribute values using the normal Python syntax:
 <p />
-<pre class="codebox">item3.TestAttribute = 'Testing'
+<pre class="codebox">newItem.TestAttribute = 'Testing'
 </pre>
 <p />
-Sets the value of item3's attribute to Testing.  We can retrieve the value of the <span class="code">TestAttribute</span> attribute by executing
+Sets the value of newItem's attribute to Testing.  We can retrieve the value of the <span class="code">TestAttribute</span> attribute by executing
 <p />
-<pre class="codebox">item3.TestAttribute
+<pre class="codebox">newItem.TestAttribute
 </pre>
 <p> Where do attributes come from? In the Chandler data model, the kind
 for an item determines what attributes are available.  In the case
@@ -481,7 +480,7 @@
 To find out what attributes are available on a kind, we can look at the
 <span class="code">attributes</span> attribute of that kind: </p>
 
-<pre class="codebox">parcelKindItem = rep.find("//Schema/Core/Parcel")
+<pre class="codebox">parcelKindItem = rep.findPath("//Schema/Core/Parcel")
 for i in parcelKindItem.attributes:
     print i
 </pre>
@@ -503,17 +502,7 @@
 assigned to the <span class="path">//Schema/Core/Parcel</span> kind -- this kind is a subkind of
 <span class="path">//Schema/Core/Item</span> and therefore it inherits Item's attributes as well.
 To get the entire list of available attributes (including those inherited
-from superkinds), you need to traverse the kind's superKinds.  There is
-a utility method available for doing so:</p>
-
-<pre class="codebox">
-from repository.parcel.Util import GetAttributes
-for i in GetAttributes(parcelKindItem): 
-    print i
-</pre>
-
-<p>This generator will return a list of tuples of the form ( Attribute, Kind ) -- an Attribute and the Kind it is inherited from.</p>
-
+from superkinds), you need to traverse the kind's superKinds.  
 <p>
 There are two kinds of attributes. Literal valued attributes store
 literal values of various types, such as numbers (integers, longs,
@@ -524,10 +513,10 @@
 numeric index, or as dictionaries, accessible by keys.  Multivalued
 reference attributes are treated as lists. 
 
-The <span class="code">Item.iterAttributes()</span> method will produce an iterator that will let you access all the attributes for an item:
+The <span class="code">Item.iterAttributeValues()</span> method will produce an iterator that will let you access all the attributes for an item:
 <pre class="codebox">
-parcel = rep.find("//parcels/simple")
-for i in parcel.iterAttributes():
+parcel = rep.findPath("//parcels/simple")
+for i in parcel.iterAttributeValues():
     print i
 </pre>
 The output looks like this:
@@ -547,7 +536,7 @@
 attributes.  </p>
 
 <pre class="codebox">
-for i in parcel.iterAttributes(valuesOnly=True):
+for i in parcel.iterAttributeValues(valuesOnly=True):
     print i
 </pre>
 produces:
@@ -561,7 +550,7 @@
 </pre></span>
 and
 <pre class="codebox">
-for i in parcel.iterAttributes(referencesOnly=True):
+for i in parcel.iterAttributeValues(referencesOnly=True):
     print i
 </pre>
 produces:
@@ -569,10 +558,10 @@
 ('kind', &lt;Kind: Parcel 760888e8-55c7-11d8-f88d-000a95bb2738&gt;)
 </pre></span>
 
-<p> You can use python's list and dictionary operation on multivalued
+<p> You can use python's list and dictionary operations on multivalued
 literal attributes.  Multivalued references attributes are a different
 story.  The repository provides an API on items that allows you to
-manipulate the values of muilti-valued reference attributes Let's try
+manipulate the values of multi-valued reference attributes.  Let's try
 this with the <span class="code">attributes</span> attribute of <span class="code">parcelKindItem</span>
 which is a list valued reference attribute.  </p>
 
@@ -586,9 +575,9 @@
 &lt;Attribute: publisher 7609f124-55c7-11d8-f88d-000a95bb2738&gt;
 </pre>
 
-Now we'll use a's UUID as a key into the <span class="code">attributes</span> attribute.
+Now we'll use <span class="code">a</span>'s UUID as a key into the <span class="code">attributes</span> attribute.
 <p />
-<pre class="codebox">print parcelKindItem.getValue('attributes', a.getUUID())
+<pre class="codebox">print parcelKindItem.getValue('attributes', a.itsUUID)
 </pre>
 <p />
 Which produces the expected result:
@@ -599,15 +588,15 @@
 <p />
 To add a new item to the list, all you would do is:
 <p />
-<pre class="codebox">parcelKindItem.addValue('attributes',item.getUUID(), item)
+<pre class="codebox">parcelKindItem.addValue('attributes',item.itsUUID, item)
 </pre>
 <p />
 To remove the value of an item in the list use removeValue:
 <p />
-<pre class="codebox">parcelKindItem.removeValue('attributes',a.getUUID())
+<pre class="codebox">parcelKindItem.removeValue('attributes',a.itsUUID)
 </pre>
 <p />
-You can also use Python operations like <span class="code">del</span> to remove a value from a multi-valued attribute. The <span class="code">append</span>, <span class="code">insert</span>, <span class="code">pop</span>, <span class="code">remove</span>, <span class="code">reverse</span>, <span class="code">sort</span>, and <span class="code">extend</span> operations are supported on list valued attributes, and the update operation is supported on dictionary valued attributes.
+You can also use Python operations like <span class="code">del</span> to remove a value from a multi-valued attribute. The <span class="code">append</span>, <span class="code">insert</span>, <span class="code">pop</span>, <span class="code">remove</span>, <span class="code">reverse</span>, <span class="code">sort</span>, and <span class="code">extend</span> operations are supported on list valued attributes, and the <span class="code">update</span> operation is supported on dictionary valued attributes.
 
 
 
@@ -647,10 +636,13 @@
 
 Please send any comments to <a href=mailto:dev at osafoundation.org>dev at osafoundation.org.</a> 
 <hr>
-$Revision: 1.8 $<br>
-$Date: 2004/02/28 01:00:13 $<br>
+$Revision: 1.9 $<br>
+$Date: 2004/10/12 20:06:12 $<br>
 $Author: twl $<br>
 $Log: repository-intro.html,v $
+Revision 1.9  2004/10/12 20:06:12  twl
+Fix bug 2113 - update repository overview for 0.4
+
 Revision 1.8  2004/02/28 01:00:13  twl
 Add motivation paragraphs
 use osaf.css



More information about the Commits mailing list