Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Store childType in the DB; childWithName() uses the childType to pick…

  • Loading branch information
m0rgen committed Nov 20, 2014
1 parent c2206e5 commit 1a3df655ce72dbd556130d03c9347f035845a1c2
Showing with 19 additions and 11 deletions.
  1. +2 −0 txdav/caldav/datastore/sql.py
  2. +13 −8 txdav/common/datastore/sql.py
  3. +4 −3 txdav/common/datastore/sql_schema/current.sql
@@ -995,6 +995,7 @@ def metadataColumns(cls):
cls._homeChildMetaDataSchema.SUPPORTED_COMPONENTS,
cls._homeChildMetaDataSchema.CREATED,
cls._homeChildMetaDataSchema.MODIFIED,
cls._homeChildMetaDataSchema.CHILD_TYPE,
)


@@ -1012,6 +1013,7 @@ def metadataAttributes(cls):
"_supportedComponents",
"_created",
"_modified",
"_childType",
)


@@ -3443,11 +3443,7 @@ def childWithName(self, name):
@param name: a string.
@return: an L{ICalendar} or C{None} if no such child exists.
"""
# FIXME: should determine the class from the collection_type column
if name == "trash":
return self._trashClass.objectWithName(self, name)
else:
return self._childClass.objectWithName(self, name)
return self._childClass.objectWithName(self, name)


def anyObjectWithShareUID(self, shareUID):
@@ -5569,6 +5565,11 @@ def makeClass(cls, home, bindData, additionalBindData, metadataData, propstore=N
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,
@@ -5829,7 +5830,6 @@ def _insertHomeChild(cls):
return Insert(
{
child.RESOURCE_ID: schema.RESOURCE_ID_SEQ,
child.COLLECTION_TYPE: Parameter("childType"),
},
Return=(child.RESOURCE_ID)
)
@@ -5844,6 +5844,7 @@ def _insertHomeChildMetaData(cls):
return Insert(
{
child.RESOURCE_ID: Parameter("resourceID"),
child.CHILD_TYPE: Parameter("childType"),
},
Return=(child.CREATED, child.MODIFIED)
)
@@ -5860,10 +5861,14 @@ def create(cls, home, name, externalID=None):
raise HomeChildNameNotAllowedError(name)

# Create this object
resourceID = (yield cls._insertHomeChild.on(home._txn, childType=cls._childType))[0][0]
resourceID = (yield cls._insertHomeChild.on(home._txn))[0][0]

# Initialize this object
_created, _modified = (yield cls._insertHomeChildMetaData.on(home._txn, resourceID=resourceID))[0]
_created, _modified = (
yield cls._insertHomeChildMetaData.on(
home._txn, resourceID=resourceID, childType=cls._childType
)
)[0]
# Bind table needs entry
yield cls._bindInsertQuery.on(
home._txn, homeID=home._resourceID, resourceID=resourceID, externalID=externalID,
@@ -92,8 +92,7 @@ insert into HOME_STATUS values (2, 'purging');
--------------

create table CALENDAR (
RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
COLLECTION_TYPE varchar(10) default null -- None, inbox, trash (FIXME: convert this to enumeration)
RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ') -- implicit index
);


@@ -132,7 +131,9 @@ create table CALENDAR_METADATA (
RESOURCE_ID integer primary key references CALENDAR on delete cascade, -- implicit index
SUPPORTED_COMPONENTS varchar(255) default null,
CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
CHILD_TYPE varchar(10) default null -- None, inbox, trash (FIXME: convert this to enumeration)

);


0 comments on commit 1a3df65

Please sign in to comment.
You can’t perform that action at this time.