[Commits] (vajda) - added type check to Cloud endpoint evaluation code

commits at osafoundation.org commits at osafoundation.org
Tue Aug 24 12:27:46 PDT 2004


Commit by: vajda
Modified files:
chandler/Makefile 1.33 1.34
chandler/parcels/osaf/contentmodel/ContentModel.py 1.26 1.27
chandler/parcels/osaf/contentmodel/mail/Mail.py 1.20 1.21
chandler/parcels/osaf/framework/attributeEditors/.cvsignore None 1.1
chandler/repository/schema/Cloud.py 1.14 1.15

Log message:
   - added type check to Cloud endpoint evaluation code
   - reworked //userdata/contentitems creation code
   - added two containers for mail parcel as version conflict workaround


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/Makefile.diff?r1=text&tr1=1.33&r2=text&tr2=1.34
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/ContentModel.py.diff?r1=text&tr1=1.26&r2=text&tr2=1.27
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/mail/Mail.py.diff?r1=text&tr1=1.20&r2=text&tr2=1.21
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/attributeEditors/.cvsignore?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Cloud.py.diff?r1=text&tr1=1.14&r2=text&tr2=1.15

Index: chandler/Makefile
diff -u chandler/Makefile:1.33 chandler/Makefile:1.34
--- chandler/Makefile:1.33	Sat Aug 21 02:30:02 2004
+++ chandler/Makefile	Tue Aug 24 12:27:40 2004
@@ -64,7 +64,5 @@
 install: $(ARCHIVES) $(notdir $(ARCHIVES))
 
 clean:
-	rm -rf $(SNAP); \
-	rm -f chandler.log; \
-	rm -rf __repository__ ; \
-	rm -f randpool.dat
+	rm -rf $(SNAP) __repository__
+	rm -f chandler.log randpool.dat

Index: chandler/parcels/osaf/contentmodel/ContentModel.py
diff -u chandler/parcels/osaf/contentmodel/ContentModel.py:1.26 chandler/parcels/osaf/contentmodel/ContentModel.py:1.27
--- chandler/parcels/osaf/contentmodel/ContentModel.py:1.26	Sat Aug 14 17:00:54 2004
+++ chandler/parcels/osaf/contentmodel/ContentModel.py	Tue Aug 24 12:27:40 2004
@@ -1,12 +1,13 @@
 """ Classes used for contentmodel parcel and kinds.
 """
 
-__revision__  = "$Revision: 1.26 $"
-__date__      = "$Date: 2004/08/15 00:00:54 $"
+__revision__  = "$Revision: 1.27 $"
+__date__      = "$Date: 2004/08/24 19:27:40 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
 from application.Parcel import Parcel
+from repository.util.Path import Path
 import repository.item.Item as Item
 import repository.item.Query as Query
 import repository.persistence.XMLRepositoryView as XMLRepositoryView
@@ -23,6 +24,7 @@
     groupKindID = None
     noteKindID = None
     conversationKindID = None
+    contentitemsPath = Path('//userdata/contentitems')
 
     # The parcel knows the UUID for the parent, once the parcel is loaded
     contentItemParentID = None
@@ -39,19 +41,22 @@
     def onItemLoad(self):
         super(ContentModel, self).onItemLoad()
         repository = self.itsView
-        parent = repository.findPath('//userdata/contentitems')
+        parent = repository.find(ContentModel.contentitemsPath)
         self._setUUIDs(parent)
 
     def startupParcel(self):
         super(ContentModel, self).startupParcel()
+
         repository = self.itsView
-        parent = repository.findPath('//userdata/contentitems')
-        if not parent:
-            itemKind = repository.findPath('//Schema/Core/Item')
-            userdata = repository.getRoot('userdata')
-            if not userdata:
-                userdata = itemKind.newItem('userdata', repository)
-            parent = itemKind.newItem('contentitems', userdata)
+        itemKind = repository.findPath('//Schema/Core/Item')
+
+        def makeContainer(parent, name, child):
+            if child is None:
+                return itemKind.newItem(name, parent)
+            else:
+                return child
+        
+        parent = repository.walk(ContentModel.contentitemsPath, makeContainer)
         self._setUUIDs(parent)
 
     def getContentItemParent(cls):

Index: chandler/parcels/osaf/contentmodel/mail/Mail.py
diff -u chandler/parcels/osaf/contentmodel/mail/Mail.py:1.20 chandler/parcels/osaf/contentmodel/mail/Mail.py:1.21
--- chandler/parcels/osaf/contentmodel/mail/Mail.py:1.20	Mon Aug 23 17:16:25 2004
+++ chandler/parcels/osaf/contentmodel/mail/Mail.py	Tue Aug 24 12:27:41 2004
@@ -1,8 +1,8 @@
 """ Classes used for Mail parcel kinds
 """
 
-__revision__  = "$Revision: 1.20 $"
-__date__      = "$Date: 2004/08/24 00:16:25 $"
+__revision__  = "$Revision: 1.21 $"
+__date__      = "$Date: 2004/08/24 19:27:41 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -12,12 +12,41 @@
 import osaf.contentmodel.Notes as Notes
 import application.Globals as Globals
 
+from repository.util.Path import Path
+
+
 class MailParcel(application.Parcel.Parcel):
 
     def startupParcel(self):
         super(MailParcel, self).startupParcel()
+
+        repository = self.itsView
+        itemKind = repository.findPath('//Schema/Core/Item')
+        contentitemsPath = ContentModel.ContentModel.contentitemsPath
+        
+        def makeContainer(parent, name, child):
+            if child is None:
+                return itemKind.newItem(name, parent)
+            else:
+                return child
+        
+        repository.walk(Path(contentitemsPath, 'inboundMailItems'),
+                        makeContainer)
+        repository.walk(Path(contentitemsPath, 'outboundMailItems'),
+                        makeContainer)
+            
         self._setUUIDs()
 
+    def getMailItemParent(cls, inbound=False):
+
+        parent = ContentModel.ContentModel.getContentItemParent()
+        if inbound:
+            return parent['inboundMailItems']
+        else:
+            return parent['outboundMailItems']
+
+    getMailItemParent = classmethod(getMailItemParent)
+
     def onItemLoad(self):
         super(MailParcel, self).onItemLoad()
         self._setUUIDs()
@@ -188,7 +217,7 @@
 class AccountBase(Item.Item):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getAccountBaseKind()
         super (AccountBase, self).__init__(name, parent, kind)
@@ -196,7 +225,7 @@
 class SMTPAccount(AccountBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getSMTPAccountKind()
         super (SMTPAccount, self).__init__(name, parent, kind)
@@ -206,7 +235,7 @@
 class IMAPAccount(AccountBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getIMAPAccountKind()
         super (IMAPAccount, self).__init__(name, parent, kind)
@@ -217,7 +246,7 @@
 class MailDeliveryError(Item.Item):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMailDeliveryErrorKind()
         super (MailDeliveryError, self).__init__(name, parent, kind)
@@ -229,7 +258,7 @@
 class MailDeliveryBase(Item.Item):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMailDeliveryBaseKind()
         super (MailDeliveryBase, self).__init__(name, parent, kind)
@@ -238,7 +267,7 @@
 class SMTPDelivery(MailDeliveryBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getSMTPDeliveryKind()
         super (SMTPDelivery, self).__init__(name, parent, kind)
@@ -263,7 +292,7 @@
 class IMAPDelivery(MailDeliveryBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getIMAPDeliveryKind()
         super (IMAPDelivery, self).__init__(name, parent, kind)
@@ -273,7 +302,7 @@
 class MIMEBase(Item.Item):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMIMEBaseKind()
         super (MIMEBase, self).__init__(name, parent, kind)
@@ -281,7 +310,7 @@
 class MIMENote(Notes.Note, MIMEBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMIMENoteKind()
         super (MIMENote, self).__init__(name, parent, kind)
@@ -289,7 +318,7 @@
 class MIMEContainer(MIMEBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMIMEContainerKind()
         super (MIMEContainer, self).__init__(name, parent, kind)
@@ -301,7 +330,7 @@
     """
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMailMessageMixinKind()
         super (MailMessageMixin, self).__init__(name, parent, kind)
@@ -377,7 +406,7 @@
 class MIMEBinary(MIMENote):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMIMEBinaryKind()
         super (MIMEBinary, self).__init__(name, parent, kind)
@@ -385,7 +414,7 @@
 class MIMEText(MIMENote):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMIMETextKind()
         super (MIMEText, self).__init__(name, parent, kind)
@@ -394,7 +423,7 @@
 class MIMESecurity(MIMEContainer):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getMIMESecurityKind()
         super (MIMESecurity, self).__init__(name, parent, kind)
@@ -402,10 +431,7 @@
 class EmailAddress(Item.Item):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
-            parent = ContentModel.ContentModel.getContentItemParent()
+            parent = MailParcel.getMailItemParent()
         if not kind:
             kind = MailParcel.getEmailAddressKind()
         super (EmailAddress, self).__init__(name, parent, kind)
-
-
-

Index: chandler/repository/schema/Cloud.py
diff -u chandler/repository/schema/Cloud.py:1.14 chandler/repository/schema/Cloud.py:1.15
--- chandler/repository/schema/Cloud.py:1.14	Thu Aug 19 11:06:30 2004
+++ chandler/repository/schema/Cloud.py	Tue Aug 24 12:27:43 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.14 $"
-__date__      = "$Date: 2004/08/19 18:06:30 $"
+__revision__  = "$Revision: 1.15 $"
+__date__      = "$Date: 2004/08/24 19:27:43 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -405,6 +405,10 @@
                 value = value.getAttributeValue(name, default=None)
                 if value is None:
                     break
+                if not (isinstance(value, Item) or
+                        isinstance(value, RefDict) or
+                        isinstance(value, PersistentCollection)):
+                    raise TypeError, type(value)
 
         if value is None:
             return []



More information about the Commits mailing list