[CalendarServer-changes] [14189] CalendarServer/branches/users/sagen/trashcan/txdav

source_changes at macosforge.org source_changes at macosforge.org
Thu Nov 20 17:59:22 PST 2014


Revision: 14189
          http://trac.calendarserver.org//changeset/14189
Author:   sagen at apple.com
Date:     2014-11-20 17:59:22 -0800 (Thu, 20 Nov 2014)
Log Message:
-----------
Update revisions table when moving to/from trash

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/trashcan/txdav/caldav/datastore/sql.py
    CalendarServer/branches/users/sagen/trashcan/txdav/common/datastore/sql.py

Modified: CalendarServer/branches/users/sagen/trashcan/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan/txdav/caldav/datastore/sql.py	2014-11-20 21:27:51 UTC (rev 14188)
+++ CalendarServer/branches/users/sagen/trashcan/txdav/caldav/datastore/sql.py	2014-11-21 01:59:22 UTC (rev 14189)
@@ -982,6 +982,43 @@
 
 
     @classmethod
+    def makeClass(cls, home, bindData, additionalBindData, metadataData, propstore=None, ownerHome=None):
+        """
+        Examine the calendar metadata to see which flavor of Calendar collection
+        to create, then call the inherited makeClass with the right class.
+
+        @param home: the parent home object
+        @type home: L{CommonHome}
+        @param bindData: the standard set of bind columns
+        @type bindData: C{list}
+        @param additionalBindData: additional bind data specific to sub-classes
+        @type additionalBindData: C{list}
+        @param metadataData: metadata data
+        @type metadataData: C{list}
+        @param propstore: a property store to use, or C{None} to load it automatically
+        @type propstore: L{PropertyStore}
+        @param ownerHome: the home of the owner, or C{None} to figure it out automatically
+        @type ownerHome: L{CommonHome}
+
+        @return: the constructed child class
+        @rtype: L{CommonHomeChild}
+        """
+
+        if metadataData:
+            childType = metadataData[3]
+            if childType == "trash":  # FIXME: make this an enumeration
+                actualClass = TrashCollection
+            else:
+                actualClass = cls
+
+            return super(Calendar, actualClass).makeClass(
+                home, bindData, additionalBindData, metadataData,
+                propstore=propstore, ownerHome=ownerHome
+            )
+
+
+
+    @classmethod
     def metadataColumns(cls):
         """
         Return a list of column name for retrieval of metadata. This allows

Modified: CalendarServer/branches/users/sagen/trashcan/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan/txdav/common/datastore/sql.py	2014-11-20 21:27:51 UTC (rev 14188)
+++ CalendarServer/branches/users/sagen/trashcan/txdav/common/datastore/sql.py	2014-11-21 01:59:22 UTC (rev 14189)
@@ -5565,11 +5565,6 @@
         else:
             ownerName = None
 
-        if metadataData:
-            collectionType = metadataData[3]
-            if collectionType == "trash":  # FIXME: make this an enumeration
-                cls = home._trashClass
-
         c = cls._externalClass if ownerHome.external() else cls
         child = c(
             home=home,
@@ -7382,6 +7377,10 @@
             self._txn, isTrash=True, resourceID=self._resourceID
         )
         yield self._parentCollection.removedObjectResource(self)
+        trash = yield self._parentCollection._home.childWithName("trash")
+        print("TO TRASH", trash)
+        if trash is not None:
+            yield trash._insertRevision(self._name)
 
 
     @inlineCallbacks
@@ -7390,6 +7389,10 @@
             self._txn, isTrash=False, resourceID=self._resourceID
         )
         yield self._parentCollection.addedObjectResource(self)
+        trash = yield self._parentCollection._home.childWithName("trash")
+        print("FROM TRASH", trash)
+        if trash is not None:
+            yield trash._deleteRevision(self._name)
 
 
     @classproperty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20141120/8ad81710/attachment.html>


More information about the calendarserver-changes mailing list