[CalendarServer-changes] [14485] CalendarServer/branches/users/sagen/trashcan-5
source_changes at macosforge.org
source_changes at macosforge.org
Fri Feb 27 13:28:03 PST 2015
Revision: 14485
http://trac.calendarserver.org//changeset/14485
Author: sagen at apple.com
Date: 2015-02-27 13:28:03 -0800 (Fri, 27 Feb 2015)
Log Message:
-----------
isTrash -> isInTrash
Modified Paths:
--------------
CalendarServer/branches/users/sagen/trashcan-5/calendarserver/tools/trash.py
CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/scheduling/processing.py
CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py
CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py
CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql_schema/current.sql
CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py
Modified: CalendarServer/branches/users/sagen/trashcan-5/calendarserver/tools/trash.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/calendarserver/tools/trash.py 2015-02-27 20:43:08 UTC (rev 14484)
+++ CalendarServer/branches/users/sagen/trashcan-5/calendarserver/tools/trash.py 2015-02-27 21:28:03 UTC (rev 14485)
@@ -96,7 +96,7 @@
if cobj is not None:
# If it's still in the trash, restore it from trash
- if (yield cobj.isTrash()):
+ if (yield cobj.isInTrash()):
print("Restoring:", name)
yield cobj.fromTrash()
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/scheduling/processing.py 2015-02-27 20:43:08 UTC (rev 14484)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/scheduling/processing.py 2015-02-27 21:28:03 UTC (rev 14485)
@@ -519,8 +519,8 @@
log.debug("ImplicitProcessing - originator '%s' to recipient '%s' processing METHOD:REQUEST, UID: '%s' - updating event" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
# Only move from trash if attendee is not fully declined:
- isTrash = yield self.recipient_calendar_resource.isTrash()
- if isTrash:
+ isInTrash = yield self.recipient_calendar_resource.isInTrash()
+ if isInTrash:
attendees = self.message.getAttendeeProperties((self.recipient.cuaddr,))
if not all([attendee.parameterValue("PARTSTAT", "NEEDS-ACTION") == "DECLINED" for attendee in attendees]):
yield self.recipient_calendar_resource.fromTrash()
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py 2015-02-27 20:43:08 UTC (rev 14484)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py 2015-02-27 21:28:03 UTC (rev 14485)
@@ -2362,7 +2362,7 @@
obj.MODIFIED,
obj.DATAVERSION,
obj.TRASHED,
- obj.IS_TRASH,
+ obj.IS_IN_TRASH,
]
@@ -2385,7 +2385,7 @@
"_modified",
"_dataversion",
"_trashed",
- "_is_trash",
+ "_is_in_trash",
)
@@ -5880,7 +5880,7 @@
From=obj.join(
bind, obj.PARENT_RESOURCE_ID == bind.RESOURCE_ID
),
- Where=(obj.IS_TRASH == True).And(
+ Where=(obj.IS_IN_TRASH == True).And(
bind.HOME_RESOURCE_ID == Parameter("resourceID")
).And(
bind.BIND_MODE == _BIND_MODE_OWN
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py 2015-02-27 20:43:08 UTC (rev 14484)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py 2015-02-27 21:28:03 UTC (rev 14485)
@@ -6093,7 +6093,22 @@
@inlineCallbacks
def remove(self):
+ """
+ Just moves the collection to the trash
+ """
+ if config.EnableTrashCollection:
+ if self.isInTrash():
+ raise AlreadyInTrashError
+ else:
+ yield self.toTrash()
+ else:
+ yield self.reallyRemove()
+
+
+ @inlineCallbacks
+ def reallyRemove(self):
+
# Stop sharing first
yield self.ownerDeleteShare()
@@ -6178,7 +6193,7 @@
def listObjectResources(self):
"""
Returns a list of names of object resources in this collection, taking
- into account the IS_TRASH flag and skipping those in the trash.
+ into account the IS_IN_TRASH flag and skipping those in the trash.
"""
if self._objectNames is None:
self._objectNames = yield self._objectResourceClass.listObjects(self)
@@ -7015,7 +7030,7 @@
rows = yield Select(
[obj.RESOURCE_NAME],
From=obj,
- Where=(obj.PARENT_RESOURCE_ID == Parameter('parentID')).And(obj.IS_TRASH == False)
+ Where=(obj.PARENT_RESOURCE_ID == Parameter('parentID')).And(obj.IS_IN_TRASH == False)
).on(parent._txn, parentID=parent.id())
returnValue(sorted([row[0] for row in rows]))
@@ -7495,18 +7510,18 @@
@classproperty
- def _updateIsTrashQuery(cls):
+ def _updateIsInTrashQuery(cls):
obj = cls._objectSchema
return Update(
- {obj.IS_TRASH: Parameter("isTrash"), obj.TRASHED: Parameter("trashed")},
+ {obj.IS_IN_TRASH: Parameter("isInTrash"), obj.TRASHED: Parameter("trashed")},
Where=obj.RESOURCE_ID == Parameter("resourceID"),
)
@inlineCallbacks
def toTrash(self):
- yield self._updateIsTrashQuery.on(
- self._txn, isTrash=True, trashed=datetime.datetime.utcnow(), resourceID=self._resourceID
+ yield self._updateIsInTrashQuery.on(
+ self._txn, isInTrash=True, trashed=datetime.datetime.utcnow(), resourceID=self._resourceID
)
yield self._parentCollection.removedObjectResource(self)
yield self._parentCollection._deleteRevision(self.name())
@@ -7525,8 +7540,8 @@
def fromTrash(self):
# First make sure this is actually in the trash
- isTrash = yield self.isTrash()
- if not isTrash:
+ isInTrash = yield self.isInTrash()
+ if not isInTrash:
returnValue(None)
if self._parentCollection.isTrash():
@@ -7543,8 +7558,8 @@
trashedName = trash.nameForResource(self._parentCollection, self)
newName = self._name
- yield self._updateIsTrashQuery.on(
- self._txn, isTrash=False, trashed=None, resourceID=self._resourceID
+ yield self._updateIsInTrashQuery.on(
+ self._txn, isInTrash=False, trashed=None, resourceID=self._resourceID
)
yield trash._deleteRevision(trashedName)
@@ -7559,11 +7574,11 @@
@classproperty
def _selectIsTrashQuery(cls):
obj = cls._objectSchema
- return Select((obj.IS_TRASH, obj.TRASHED), From=obj, Where=obj.RESOURCE_ID == Parameter("resourceID"))
+ return Select((obj.IS_IN_TRASH, obj.TRASHED), From=obj, Where=obj.RESOURCE_ID == Parameter("resourceID"))
@inlineCallbacks
- def isTrash(self):
+ def isInTrash(self):
returnValue(
(
yield self._selectIsTrashQuery.on(
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql_schema/current.sql
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql_schema/current.sql 2015-02-27 20:43:08 UTC (rev 14484)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql_schema/current.sql 2015-02-27 21:28:03 UTC (rev 14485)
@@ -134,7 +134,7 @@
MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
CHILD_TYPE varchar(10) default null, -- None, inbox, trash (FIXME: convert this to enumeration)
TRASHED timestamp default null,
- IS_TRASH boolean default false not null -- collection is in the trash
+ IS_IN_TRASH boolean default false not null -- collection is in the trash
);
@@ -263,7 +263,7 @@
MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
DATAVERSION integer default 0 not null,
TRASHED timestamp default null,
- IS_TRASH boolean default false not null, -- entire resource is in the trash
+ IS_IN_TRASH boolean default false not null, -- entire resource is in the trash
unique (CALENDAR_RESOURCE_ID, RESOURCE_NAME) -- implicit index
@@ -485,7 +485,7 @@
MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
DATAVERSION integer default 0 not null,
TRASHED timestamp default null,
- IS_TRASH boolean default false not null,
+ IS_IN_TRASH boolean default false not null,
unique (ADDRESSBOOK_HOME_RESOURCE_ID, RESOURCE_NAME), -- implicit index
unique (ADDRESSBOOK_HOME_RESOURCE_ID, VCARD_UID) -- implicit index
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py 2015-02-27 20:43:08 UTC (rev 14484)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py 2015-02-27 21:28:03 UTC (rev 14485)
@@ -632,7 +632,7 @@
self.assertEquals(len(objects), 0)
# Verify it's not in the trash
- self.assertFalse((yield resource.isTrash()))
+ self.assertFalse((yield resource.isInTrash()))
trashed = yield resource.whenTrashed()
self.assertTrue(trashed is None)
@@ -646,7 +646,7 @@
# Verify it's in the trash
resource = yield self._getResource(txn, "user01", "trash", "")
- self.assertTrue((yield resource.isTrash()))
+ self.assertTrue((yield resource.isInTrash()))
trashed = yield resource.whenTrashed()
self.assertFalse(trashed is None)
@@ -675,7 +675,7 @@
resourceNames = yield self._getResourceNames(txn, "user01", "calendar")
self.assertEqual(len(resourceNames), 1)
resource = yield self._getResource(txn, "user01", "calendar", "test.ics")
- self.assertFalse((yield resource.isTrash()))
+ self.assertFalse((yield resource.isInTrash()))
trashed = yield resource.whenTrashed()
self.assertTrue(trashed is None)
@@ -719,13 +719,13 @@
# self.assertEquals(len(objects), 1)
# # Verify it's not in the trash
-# self.assertFalse((yield resource.isTrash()))
+# self.assertFalse((yield resource.isInTrash()))
# # Move object to trash
# yield resource.toTrash()
# # Verify it's in the trash
-# self.assertTrue((yield resource.isTrash()))
+# self.assertTrue((yield resource.isInTrash()))
# # No objects
# objects = yield collection.listObjectResources()
@@ -742,7 +742,7 @@
# yield resource.fromTrash()
# # Not in trash
-# self.assertFalse((yield resource.isTrash()))
+# self.assertFalse((yield resource.isInTrash()))
# # One object
# objects = yield collection.listObjectResources()
@@ -854,7 +854,7 @@
# user01's copy is in the trash, still with user02 accepted
txn = self.store.newTransaction()
resource = yield self._getResource(txn, "user01", "trash", "")
- self.assertTrue((yield resource.isTrash()))
+ self.assertTrue((yield resource.isInTrash()))
trashed = yield resource.whenTrashed()
self.assertFalse(trashed is None)
data = yield self._getResourceData(txn, "user01", "trash", "")
@@ -888,7 +888,7 @@
# user01's copy should be back on their calendar
resource = yield self._getResource(txn, "user01", "calendar", "test.ics")
- self.assertFalse((yield resource.isTrash()))
+ self.assertFalse((yield resource.isInTrash()))
trashed = yield resource.whenTrashed()
self.assertTrue(trashed is None)
data = yield self._getResourceData(txn, "user01", "calendar", "test.ics")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150227/6da5108a/attachment-0001.html>
More information about the calendarserver-changes
mailing list