[CalendarServer-changes] [1941] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Thu Oct 4 09:35:41 PDT 2007


Revision: 1941
          http://trac.macosforge.org/projects/calendarserver/changeset/1941
Author:   cdaboo at apple.com
Date:     2007-10-04 09:35:40 -0700 (Thu, 04 Oct 2007)

Log Message:
-----------
Make sure caladmin per-principal data is correct and displays short names rather than uuids.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/admin/principals.py
    CalendarServer/trunk/twistedcaldav/admin/util.py
    CalendarServer/trunk/twistedcaldav/directory/principal.py

Modified: CalendarServer/trunk/twistedcaldav/admin/principals.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/principals.py	2007-10-03 21:10:14 UTC (rev 1940)
+++ CalendarServer/trunk/twistedcaldav/admin/principals.py	2007-10-04 16:35:40 UTC (rev 1941)
@@ -16,11 +16,11 @@
 # DRI: David Reid, dreid at apple.com
 ##
 """
- Account Stats: 
-  # of calendars
-  # of events
-  # storage used (including things that don't count against quota?)
-  Last login?
+    Account Stats: 
+        # of calendars
+        # of events
+        # storage used (including things that don't count against quota?)
+        Last login?
 """
 
 from twistedcaldav.admin import util
@@ -64,25 +64,39 @@
                 
                 pcal = self.calendarCollection.child(
                     self.type
-                    ).child(p.basename())
+                    ).child(util.getPrincipalName(p))
             
-                precord['principalName'] = p.basename()
+                precord['principalName'] = util.getPrincipalName(p)
                 
-                precord['calendarHome'] = pcal.path
+                if pcal.exists():
+                    precord['calendarHome'] = pcal.path
+    
+                    precord.update(
+                        util.getQuotaStatsForPrincipal(
+                            self.config,
+                            pcal,
+                            self.quota))
+    
+                    precord.update(
+                        util.getCalendarDataCounts(pcal))
+    
+                    precord['diskUsage'] = util.getDiskUsage(self.config, pcal)
+                    
+                    precord['disabled'] = util.isPrincipalDisabled(p)
+                else:
+                    precord.update({
+                        'calendarHome':  "-",
+                        'quotaRoot':     "-",
+                        'quotaUsed':     "-",
+                        'quotaAvail':    "-",
+                        'quotaFree':     "-",
+                        'calendarCount': "-",
+                        'eventCount':    "-",
+                        'todoCount':     "-",
+                        'diskUsage':     "-",
+                        'disabled':      "-",
+                    })
 
-                precord.update(
-                    util.getQuotaStatsForPrincipal(
-                        self.config,
-                        pcal,
-                        self.quota))
-
-                precord.update(
-                    util.getCalendarDataCounts(pcal))
-
-                precord['diskUsage'] = util.getDiskUsage(self.config, pcal)
-                
-                precord['disabled'] = util.isPrincipalDisabled(p)
-                
                 yield precord
 
         report['records'] = _getRecords()

Modified: CalendarServer/trunk/twistedcaldav/admin/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/util.py	2007-10-03 21:10:14 UTC (rev 1940)
+++ CalendarServer/trunk/twistedcaldav/admin/util.py	2007-10-04 16:35:40 UTC (rev 1941)
@@ -24,7 +24,7 @@
 
 from twisted.web import microdom
 
-from twistedcaldav.directory.principal import RecordTypeProperty
+from twistedcaldav.directory.principal import RecordTypeProperty, RecordNameProperty
 from twistedcaldav.sql import db_prefix, AbstractSQLDatabase
 from twistedcaldav.index import schema_version, collection_types
 
@@ -102,6 +102,17 @@
 
     return rtp[0].firstChild().value
     
+def getPrincipalName(fp):
+    rtp = "WebDAV:" + RecordNameProperty.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-name')
+
+    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-03 21:10:14 UTC (rev 1940)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py	2007-10-04 16:35:40 UTC (rev 1941)
@@ -380,6 +380,7 @@
         result = super(DirectoryPrincipalResource, self).provisionFile()
         if result:
             self.writeDeadProperty(RecordTypeProperty(self.record.recordType))
+            self.writeDeadProperty(RecordNameProperty(self.record.shortName))
         return result
 
     ##
@@ -732,3 +733,9 @@
     name = "record-type"
 
 davxml.registerElement(RecordTypeProperty)
+
+class RecordNameProperty (davxml.WebDAVTextElement):
+    namespace = twisted_private_namespace
+    name = "record-name"
+
+davxml.registerElement(RecordNameProperty)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20071004/a3f39415/attachment.html


More information about the calendarserver-changes mailing list