[CalendarServer-changes] [1933] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 1 10:29:11 PDT 2007
Revision: 1933
http://trac.macosforge.org/projects/calendarserver/changeset/1933
Author: cdaboo at apple.com
Date: 2007-10-01 10:29:10 -0700 (Mon, 01 Oct 2007)
Log Message:
-----------
Make sure we can read account stats from the new __uids__ principal resource types.
Also produce better warnings when caladmin cannot access the doc root.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/admin/stats.py
CalendarServer/trunk/twistedcaldav/admin/util.py
CalendarServer/trunk/twistedcaldav/directory/principal.py
Modified: CalendarServer/trunk/twistedcaldav/admin/stats.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/stats.py 2007-10-01 15:30:55 UTC (rev 1932)
+++ CalendarServer/trunk/twistedcaldav/admin/stats.py 2007-10-01 17:29:10 UTC (rev 1933)
@@ -19,12 +19,15 @@
"""
Statisitcs Types:
- Overall Stats:
- # of accounts
- # of calendars
- # of events
+ Overall Stats:
+ # of accounts
+ # of calendars
+ # of events
"""
+
+import os
+
from twistedcaldav.admin import util
class StatsAction(object):
@@ -75,8 +78,8 @@
'locations')))
def run(self):
- assert self.root.exists()
- stats = []
+ assert self.root.exists(), "Calendar server document root directory does not exist: %s" % (self.root.path,)
+ assert os.access(self.root.path, os.R_OK), "Cannot read calendar server document root directory: %s" % (self.root.path,)
report = {'type': 'stats',
'data': {}}
Modified: CalendarServer/trunk/twistedcaldav/admin/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/util.py 2007-10-01 15:30:55 UTC (rev 1932)
+++ CalendarServer/trunk/twistedcaldav/admin/util.py 2007-10-01 17:29:10 UTC (rev 1933)
@@ -24,7 +24,7 @@
from twisted.web import microdom
-from twistedcaldav import ical
+from twistedcaldav.directory.principal import RecordTypeProperty
from twistedcaldav.sql import db_prefix, AbstractSQLDatabase
from twistedcaldav.index import schema_version, collection_types
@@ -62,7 +62,7 @@
def getPrincipalList(principalCollection, type, disabled=False):
- typeRoot = principalCollection.child(type)
+ typeRoot = principalCollection.child("__uids__")
pl = []
@@ -70,12 +70,13 @@
for child in typeRoot.listdir():
if not child.startswith(db_prefix):
p = typeRoot.child(child)
-
- if disabled:
- if isPrincipalDisabled(p):
+ ptype = getPrincipalType(p)
+ if ptype == type:
+ if disabled:
+ if isPrincipalDisabled(p):
+ pl.append(p)
+ else:
pl.append(p)
- else:
- pl.append(p)
return pl
@@ -90,6 +91,17 @@
return prepareByteValue(config, int(output.split()[0]))
+def getPrincipalType(fp):
+ rtp = "WebDAV:" + RecordTypeProperty.sname().replace("/", "%2F")
+ x = xattr.xattr(fp.path)
+ if not x.has_key(rtp):
+ return None
+
+ dom = microdom.parseString(_getxattr_value(x, rtp))
+ rtp = microdom.getElementsByTagName(dom, 'record-type')
+
+ return rtp[0].firstChild().value
+
def getResourceType(fp):
rt = 'WebDAV:{DAV:}resourcetype'
x = xattr.xattr(fp.path)
Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py 2007-10-01 15:30:55 UTC (rev 1932)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py 2007-10-01 17:29:10 UTC (rev 1933)
@@ -37,6 +37,7 @@
from twisted.web2 import responsecode
from twisted.web2.http import HTTPError
from twisted.web2.dav import davxml
+from twisted.web2.dav.element.base import twisted_private_namespace
from twisted.web2.dav.util import joinURL
from twistedcaldav.config import config
@@ -374,6 +375,13 @@
def __str__(self):
return "(%s) %s" % (self.record.recordType, self.record.shortName)
+ def provisionFile(self):
+
+ result = super(DirectoryPrincipalResource, self).provisionFile()
+ if result:
+ self.writeDeadProperty(RecordTypeProperty(self.record.recordType))
+ return result
+
##
# HTTP
##
@@ -718,3 +726,9 @@
davxml.Protected(),
),
)
+
+class RecordTypeProperty (davxml.WebDAVTextElement):
+ namespace = twisted_private_namespace
+ name = "record-type"
+
+davxml.registerElement(RecordTypeProperty)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20071001/554034da/attachment-0001.html
More information about the calendarserver-changes
mailing list