[CalendarServer-changes] [498]
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/
directory/xmlfile.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Nov 16 18:15:33 PST 2006
Revision: 498
http://trac.macosforge.org/projects/calendarserver/changeset/498
Author: wsanchez at apple.com
Date: 2006-11-16 18:15:33 -0800 (Thu, 16 Nov 2006)
Log Message:
-----------
Re-read XML file if it has changed.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/xmlfile.py
Modified: CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/xmlfile.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/xmlfile.py 2006-11-17 01:35:00 UTC (rev 497)
+++ CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/xmlfile.py 2006-11-17 02:15:33 UTC (rev 498)
@@ -43,7 +43,8 @@
if type(xmlFile) is str:
xmlFile = FilePath(xmlFile)
- self.xmlAccounts = XMLAccountsParser(xmlFile)
+ self.xmlFile = xmlFile
+ self._fileInfo = None
def recordTypes(self):
recordTypes = ("user", "group", "resource")
@@ -69,10 +70,17 @@
raise NotImplementedError()
def _entriesForRecordType(self, recordType):
- for entry in self.xmlAccounts.items.itervalues():
+ for entry in self._accounts().itervalues():
if entry.recordType == recordType:
yield entry.uid, entry
+ def _accounts(self):
+ fileInfo = (self.xmlFile.getmtime(), self.xmlFile.getsize())
+ if fileInfo != self._fileInfo:
+ self._parsedAccounts = XMLAccountsParser(self.xmlFile).items
+ self._fileInfo = fileInfo
+ return self._parsedAccounts
+
class XMLDirectoryRecord(DirectoryRecord):
"""
XML based implementation implementation of L{IDirectoryRecord}.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061116/36e044c2/attachment.html
More information about the calendarserver-changes
mailing list