[CalendarServer-changes] [6102] CalendarServer/trunk/txcaldav/calendarstore

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 18 07:19:47 PDT 2010


Revision: 6102
          http://trac.macosforge.org/projects/calendarserver/changeset/6102
Author:   cdaboo at apple.com
Date:     2010-08-18 07:19:47 -0700 (Wed, 18 Aug 2010)
Log Message:
-----------
Add created/modified properties for some objects.

Modified Paths:
--------------
    CalendarServer/trunk/txcaldav/calendarstore/postgres.py
    CalendarServer/trunk/txcaldav/calendarstore/postgres_schema_v1.sql

Modified: CalendarServer/trunk/txcaldav/calendarstore/postgres.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/postgres.py	2010-08-18 01:44:51 UTC (rev 6101)
+++ CalendarServer/trunk/txcaldav/calendarstore/postgres.py	2010-08-18 14:19:47 UTC (rev 6102)
@@ -381,9 +381,9 @@
             self._txn.execSQL(
                 """
                 update CALENDAR_OBJECT set
-                (ICALENDAR_TEXT, ICALENDAR_UID, ICALENDAR_TYPE, ATTACHMENTS_MODE, ORGANIZER, RECURRANCE_MAX)
+                (ICALENDAR_TEXT, ICALENDAR_UID, ICALENDAR_TYPE, ATTACHMENTS_MODE, ORGANIZER, RECURRANCE_MAX, MODIFIED)
                  =
-                (%s, %s, %s, %s, %s, %s)
+                (%s, %s, %s, %s, %s, %s, timezone('UTC', CURRENT_TIMESTAMP))
                  where RESOURCE_ID = %s
                 """,
                 # should really be filling out more fields: ORGANIZER,
@@ -563,15 +563,26 @@
 
 
     def size(self):
-        return 0
+        size = self._txn.execSQL(
+            "select character_length(ICALENDAR_TEXT) from CALENDAR_OBJECT where "
+            "RESOURCE_ID = %s", [self._resourceID]
+        )[0][0]
+        return size
 
 
     def created(self):
-        return None
+        created = self._txn.execSQL(
+            "select extract(EPOCH from CREATED) from CALENDAR_OBJECT where "
+            "RESOURCE_ID = %s", [self._resourceID]
+        )[0][0]
+        return int(created)
 
-
     def modified(self):
-        return None
+        modified = self._txn.execSQL(
+            "select extract(EPOCH from MODIFIED) from CALENDAR_OBJECT where "
+            "RESOURCE_ID = %s", [self._resourceID]
+        )[0][0]
+        return int(modified)
 
 
     def attendeesCanManageAttachments(self):
@@ -606,12 +617,15 @@
         """
         rows = self._txn.execSQL(
             """
-            select CONTENT_TYPE, MD5 from ATTACHMENT where PATH = %s
+            select CONTENT_TYPE, SIZE, MD5, extract(EPOCH from CREATED), extract(EPOCH from MODIFIED) from ATTACHMENT where PATH = %s
             """, [self._pathValue()])
         if not rows:
             return False
         self._contentType = MimeType.fromString(rows[0][0])
-        self._md5 = rows[0][1]
+        self._size = rows[0][1]
+        self._md5 = rows[0][2]
+        self._created = int(rows[0][3])
+        self._modified = int(rows[0][4])
         return True
 
 
@@ -638,15 +652,14 @@
 
 
     def size(self):
-        return 0
+        return self._size
 
 
     def created(self):
-        return None
+        return self._created
 
-
     def modified(self):
-        return None
+        return self._modified
 
 
     def name(self):
@@ -689,9 +702,9 @@
         pathValue = self.attachment._pathValue()
         contentTypeString = generateContentType(self.contentType)
         self._txn.execSQL(
-            "update ATTACHMENT set CONTENT_TYPE = %s, MD5 = %s "
+            "update ATTACHMENT set CONTENT_TYPE = %s, SIZE = %s, MD5 = %s, MODIFIED = timezone('UTC', CURRENT_TIMESTAMP) "
             "WHERE PATH = %s",
-            [contentTypeString, self.hash.hexdigest(), pathValue]
+            [contentTypeString, len(self.buf), self.hash.hexdigest(), pathValue]
         )
 
 
@@ -1375,14 +1388,20 @@
 
 
     def created(self):
-        return None
+        created = self._txn.execSQL(
+            "select extract(EPOCH from CREATED) from CALENDAR where "
+            "RESOURCE_ID = %s", [self._resourceID]
+        )[0][0]
+        return int(created)
 
-
     def modified(self):
-        return None
+        modified = self._txn.execSQL(
+            "select extract(EPOCH from MODIFIED) from CALENDAR where "
+            "RESOURCE_ID = %s", [self._resourceID]
+        )[0][0]
+        return int(modified)
 
 
-
 class PostgresCalendarHome(object):
 
     implements(ICalendarHome)

Modified: CalendarServer/trunk/txcaldav/calendarstore/postgres_schema_v1.sql
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/postgres_schema_v1.sql	2010-08-18 01:44:51 UTC (rev 6101)
+++ CalendarServer/trunk/txcaldav/calendarstore/postgres_schema_v1.sql	2010-08-18 14:19:47 UTC (rev 6102)
@@ -21,7 +21,9 @@
 
 create table CALENDAR (
   RESOURCE_ID integer      primary key default nextval('RESOURCE_ID_SEQ'),
-  SYNC_TOKEN  varchar(255)
+  SYNC_TOKEN  varchar(255),
+  CREATED     timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED    timestamp default timezone('UTC', CURRENT_TIMESTAMP)
 );
 
 
@@ -120,6 +122,8 @@
   ORGANIZER            varchar(255),
   ORGANIZER_OBJECT     integer      references CALENDAR_OBJECT,
   RECURRANCE_MAX       date,        -- maximum date that recurrences have been expanded to.
+  CREATED              timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED             timestamp default timezone('UTC', CURRENT_TIMESTAMP),
 
   unique(CALENDAR_RESOURCE_ID, RESOURCE_NAME)
 
@@ -197,6 +201,8 @@
   CONTENT_TYPE                varchar(255)  not null,
   SIZE                        integer       not null,
   MD5                         char(32)      not null,
+  CREATED                     timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED                    timestamp default timezone('UTC', CURRENT_TIMESTAMP),
   PATH                        varchar(1024) not null unique
 );
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100818/42167bd8/attachment.html>


More information about the calendarserver-changes mailing list