[CalendarServer-changes] [13425] CalendarServer/trunk/txdav/who/util.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri May 2 19:39:23 PDT 2014
Revision: 13425
http://trac.calendarserver.org//changeset/13425
Author: sagen at apple.com
Date: 2014-05-02 19:39:23 -0700 (Fri, 02 May 2014)
Log Message:
-----------
If a directory xml file is missing, create with an emtpy <directory/> element.
Modified Paths:
--------------
CalendarServer/trunk/txdav/who/util.py
Modified: CalendarServer/trunk/txdav/who/util.py
===================================================================
--- CalendarServer/trunk/txdav/who/util.py 2014-05-03 02:37:18 UTC (rev 13424)
+++ CalendarServer/trunk/txdav/who/util.py 2014-05-03 02:39:23 UTC (rev 13425)
@@ -15,8 +15,6 @@
##
-import os
-
from calendarserver.tap.util import getDBPool, storeFromConfig
from twext.python.log import Logger
from twext.python.types import MappingProxyType
@@ -80,13 +78,15 @@
# TODO: add a "test" directory service that produces test records
# from code -- no files needed.
+ # The InMemoryDirectoryService now exists, it just needs hooking up
+ # here.
if "xml" in directoryType:
xmlFile = params.xmlFile
xmlFile = fullServerPath(config.DataRoot, xmlFile)
- if not xmlFile or not os.path.exists(xmlFile):
- log.error("Path not found for XML directory: {p}", p=xmlFile)
fp = FilePath(xmlFile)
+ if not fp.exists():
+ fp.setContent(DEFAULT_XML_CONTENT)
directory = XMLDirectoryService(fp)
elif "opendirectory" in directoryType:
@@ -245,7 +245,12 @@
return augmented
+DEFAULT_XML_CONTENT = """<?xml version="1.0" encoding="utf-8"?>
+<directory realm="Realm"/>
+"""
+
+
class InMemoryDirectoryService(IndexDirectoryService):
"""
An in-memory IDirectoryService. You must call updateRecords( ) if you want
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140502/9eb5a783/attachment.html>
More information about the calendarserver-changes
mailing list