[Commits] (morgen) Parcel Loader changes: Kinds that don't have any superKinds assigned

commits at osafoundation.org commits at osafoundation.org
Tue Jun 29 18:25:05 PDT 2004


Commit by: morgen
Modified files:
chandler/application/Application.py 1.244 1.245
chandler/application/Parcel.py 1.10 1.11
chandler/application/tests/TestLocalAttrs.py 1.1 1.2
chandler/parcels/osaf/framework/blocks/Events/parcel.xml 1.29 1.30
chandler/parcels/osaf/framework/crypto/.cvsignore None 1.1
chandler/parcels/osaf/views/main/Main.py 1.8 1.9
chandler/parcels/osaf/views/main/parcel.xml 1.52 1.53

Log message:
Parcel Loader changes:  Kinds that don't have any superKinds assigned
are automatically assigned //Schema/Core/Item as a superKind; Local
attribute items are automatically linked to their parent kind item.

PyCrust:  A new menu item has been added to the "Test" menu which
will bring up the PyCrust debugger window; this includes an interactive
python shell, and also a data browser.  Expand "locals()" in the
lower-left corner to explore.  I have populated "locals()" with a
few handy starting points: "chandler" is the wxApplication, "Globals"
is application.Globals, "repo" is the repository, "pm" is the parcel
manager.



ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/Application.py.diff?r1=text&tr1=1.244&r2=text&tr2=1.245
http://cvs.osafoundation.org/index.cgi/chandler/application/Parcel.py.diff?r1=text&tr1=1.10&r2=text&tr2=1.11
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/TestLocalAttrs.py.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/Events/parcel.xml.diff?r1=text&tr1=1.29&r2=text&tr2=1.30
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/crypto/.cvsignore?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.8&r2=text&tr2=1.9
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/parcel.xml.diff?r1=text&tr1=1.52&r2=text&tr2=1.53

Index: chandler/parcels/osaf/views/main/parcel.xml
diff -u chandler/parcels/osaf/views/main/parcel.xml:1.52 chandler/parcels/osaf/views/main/parcel.xml:1.53
--- chandler/parcels/osaf/views/main/parcel.xml:1.52	Tue Jun 29 13:02:26 2004
+++ chandler/parcels/osaf/views/main/parcel.xml	Tue Jun 29 18:25:03 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.52 $ -->
-<!-- $Date: 2004/06/29 20:02:26 $ -->
+<!-- $Revision: 1.53 $ -->
+<!-- $Date: 2004/06/30 01:25:03 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -211,6 +211,13 @@
     <helpString>run check() on the current view</helpString>
   </MenuItem>
 
+  <MenuItem itsName="ShowPyCrustItem">
+    <title>Show PyCrust Debugger</title>
+    <menuLocation>TestMenu</menuLocation>
+    <event itemref="events:ShowPyCrust"/>
+    <helpString>Brings up an interactive Python shell</helpString>
+  </MenuItem>
+
   <!--
     Toolbars
   -->
@@ -437,6 +444,7 @@
     <childrenBlocks itemref="doc:GenerateNoteItem"/>
     <childrenBlocks itemref="doc:ImportContactItem"/>
     <childrenBlocks itemref="doc:CheckRepositoryItem"/>
+    <childrenBlocks itemref="doc:ShowPyCrustItem"/>
     
     <!-- Toolbar -->
     <childrenBlocks itemref="doc:NavigationBar"/>

Index: chandler/application/Parcel.py
diff -u chandler/application/Parcel.py:1.10 chandler/application/Parcel.py:1.11
--- chandler/application/Parcel.py:1.10	Mon Jun 28 16:05:08 2004
+++ chandler/application/Parcel.py	Tue Jun 29 18:25:02 2004
@@ -141,6 +141,9 @@
         # Initialize any attributes that aren't persisted:
         self.repo = repository
         self.lastError = None
+        self.kindUUID = repository.findPath("//Schema/Core/Kind").itsUUID
+        self.itemUUID = repository.findPath("//Schema/Core/Item").itsUUID
+        self.attrUUID = repository.findPath("//Schema/Core/Attribute").itsUUID
 
 
     def lookup(self, namespace, name=None):
@@ -745,6 +748,13 @@
         for (item, attributes) in self.delayedAssigments:
             self.completeAssignments(item, attributes)
 
+        # Here we can perform any additional item clean-up such as ensuring a
+        # superKind has been assigned to a kind, or local attributes have been
+        # linked up:
+        for item in self.itemsCreated:
+            self.itemPostProcess(item)
+
+
         # Uncomment the following lines for file-by-file printouts of what
         # items are being created:
 
@@ -879,6 +889,7 @@
                "name"       : name,
                "key"        : None,
                "copyName"   : self.currentCopyName,
+               "file"       : self.locator.getSystemId(),
                "line"       : self.locator.getLineNumber()
             }
             self.currentAssigments.append(assignment)
@@ -925,6 +936,7 @@
                    "typePath"   : self.currentType,
                    "value"      : self.currentValue,
                    "key"        : None,
+                   "file"       : self.locator.getSystemId(),
                    "line"       : self.locator.getLineNumber()
                  }
                 )
@@ -944,6 +956,7 @@
                    "typePath"   : self.currentType,
                    "value"      : self.currentValue,
                    "key"        : self.currentKey,
+                   "file"       : self.locator.getSystemId(),
                    "line"       : self.locator.getLineNumber()
                  }
                 )
@@ -984,6 +997,26 @@
 
         self.mapping[prefix] = None
 
+    def itemPostProcess(self, item):
+        """ Perform any post-creation-processing such as ensuring a superkind
+            has been assigned to a kind, or local attributes have been hooked
+            up """
+
+        isItemAKind = (item.itsKind.itsUUID == self.manager.kindUUID)
+
+        if isItemAKind:
+            # Assign superKind of //Schema/Core/Item if none assigned
+            if not item.hasAttributeValue("superKinds") or \
+             (len(item.superKinds) == 0):
+                item.addValue("superKinds",
+                 self.repository.findUUID(self.manager.itemUUID))
+
+            # Hook up any local attributes to this kind
+            if item.hasChildren():
+                for child in item:
+                    if child.itsKind.itsUUID == self.manager.attrUUID:
+                        # child is an attribute
+                        item.addValue("attributes", child)
 
     def makeValue(self, item, attributeName, attributeTypePath, value, line):
         """ Creates a value from a string, based on the type
@@ -1114,6 +1147,7 @@
 
             attributeName = assignment["attrName"]
             line = assignment["line"]
+            file = assignment["file"]
             if assignment.has_key("key"):
                 key = assignment["key"]
             else:
@@ -1135,7 +1169,7 @@
                     reference = self.findItem(namespace, name, line)
                     if reference is None:
                         raise self.saveErrorState("Referenced item doesn't " \
-                         "exist: %s:%s" % (namespace, name), None, line)
+                         "exist: %s:%s" % (namespace, name), file, line)
 
                 # @@@ Special cases to resolve
                 if copyName:
@@ -1166,7 +1200,7 @@
                         item.addValue(attributeName, value)
                 except:
                     raise self.saveErrorState("Couldn't add value to item ",
-                     None, line)
+                     file, line)
 
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 

Index: chandler/application/tests/TestLocalAttrs.py
diff -u chandler/application/tests/TestLocalAttrs.py:1.1 chandler/application/tests/TestLocalAttrs.py:1.2
--- chandler/application/tests/TestLocalAttrs.py:1.1	Mon Jun 21 17:48:23 2004
+++ chandler/application/tests/TestLocalAttrs.py	Tue Jun 29 18:25:02 2004
@@ -1,8 +1,8 @@
 """
 Parcel Loader test for local attributes
 """
-__revision__  = "$Revision: 1.1 $"
-__date__      = "$Date: 2004/06/22 00:48:23 $"
+__revision__  = "$Revision: 1.2 $"
+__date__      = "$Date: 2004/06/30 01:25:02 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -41,6 +41,4 @@
 
 
 if __name__ == "__main__":
-    # unittest.main()
-    # Disabling this test until the parcel loader handles locals properly
-    pass
+    unittest.main()

Index: chandler/parcels/osaf/framework/blocks/Events/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.29 chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.30
--- chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.29	Mon Jun 21 17:52:00 2004
+++ chandler/parcels/osaf/framework/blocks/Events/parcel.xml	Tue Jun 29 18:25:03 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.29 $ -->
-<!-- $Date: 2004/06/22 00:52:00 $ -->
+<!-- $Revision: 1.30 $ -->
+<!-- $Date: 2004/06/30 01:25:03 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -34,6 +34,7 @@
     <subscribeAlwaysEvents itemref="events:GenerateNotes"/>
     <subscribeAlwaysEvents itemref="events:GenerateCalendarEventItems"/>    
     <subscribeAlwaysEvents itemref="events:CheckRepository"/>
+    <subscribeAlwaysEvents itemref="events:ShowPyCrust"/>
   </EventList>
 
   <BlockEvent itsName="New">
@@ -109,4 +110,8 @@
     <dispatchEnum>ActiveViewBubbleUp</dispatchEnum>
   </BlockEvent>
 
+  <BlockEvent itsName="ShowPyCrust">
+    <dispatchEnum>ActiveViewBubbleUp</dispatchEnum>
+  </BlockEvent>
+
 </core:Parcel>

Index: chandler/application/Application.py
diff -u chandler/application/Application.py:1.244 chandler/application/Application.py:1.245
--- chandler/application/Application.py:1.244	Mon Jun 28 21:46:14 2004
+++ chandler/application/Application.py	Tue Jun 29 18:25:02 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.244 $"
-__date__ = "$Date: 2004/06/29 04:46:14 $"
+__version__ = "$Revision: 1.245 $"
+__date__ = "$Date: 2004/06/30 01:25:02 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -459,14 +459,14 @@
         wx.PostEvent(self, evt)
         return evt.lock
 
-    if __debug__:
-        def ShowDebuggerWindow(self, event):
-            import wx.py
-            self.crustFrame = wx.py.crust.CrustFrame()
-            self.crustFrame.SetSize((700,700))
-            self.crustFrame.Show(True)
-            self.crustFrame.shell.interp.locals['chandler'] = self
-            self.crustFrame.Bind(wx.EVT_CLOSE, self.OnCloseDebuggerWindow)
-
-        def onCloseDebuggerWindow(self, event):
-            self.crustFrame.Destroy()
+    def ShowDebuggerWindow(self):
+        import wx.py
+        self.crustFrame = wx.py.crust.CrustFrame()
+        self.crustFrame.SetSize((700,700))
+        self.crustFrame.Show(True)
+        self.crustFrame.shell.interp.locals['chandler'] = self
+        self.crustFrame.shell.interp.locals['Globals'] = application.Globals
+        self.crustFrame.shell.interp.locals['repo'] = \
+         application.Globals.repository
+        self.crustFrame.shell.interp.locals['pm'] = \
+         application.Parcel.Manager.getManager()

Index: chandler/parcels/osaf/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.8 chandler/parcels/osaf/views/main/Main.py:1.9
--- chandler/parcels/osaf/views/main/Main.py:1.8	Fri Jun 11 08:35:08 2004
+++ chandler/parcels/osaf/views/main/Main.py	Tue Jun 29 18:25:03 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.8 $"
-__date__ = "$Date: 2004/06/11 15:35:08 $"
+__version__ = "$Revision: 1.9 $"
+__date__ = "$Date: 2004/06/30 01:25:03 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -67,3 +67,7 @@
             repository.logger.info('Check completed successfully')
         else:
             repository.logger.info('Check completed with errors')
+
+    def onShowPyCrustEvent(self, notification):
+        Globals.wxApplication.ShowDebuggerWindow()
+



More information about the Commits mailing list