[CalendarServer-changes] [15069] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 26 11:01:05 PDT 2015


Revision: 15069
          http://trac.calendarserver.org//changeset/15069
Author:   cdaboo at apple.com
Date:     2015-08-26 11:01:05 -0700 (Wed, 26 Aug 2015)
Log Message:
-----------
Log sync and sync-home separately. Log more detail about POST requests. Include display of method usage in dashboard.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/accesslog.py
    CalendarServer/trunk/calendarserver/logAnalysis.py
    CalendarServer/trunk/calendarserver/tools/dashboard.py
    CalendarServer/trunk/contrib/tools/protocolanalysis.py
    CalendarServer/trunk/twistedcaldav/method/post.py

Modified: CalendarServer/trunk/calendarserver/accesslog.py
===================================================================
--- CalendarServer/trunk/calendarserver/accesslog.py	2015-08-26 17:25:45 UTC (rev 15068)
+++ CalendarServer/trunk/calendarserver/accesslog.py	2015-08-26 18:01:05 UTC (rev 15069)
@@ -493,6 +493,8 @@
         current["user-agent"][adjustedClient] += 1
         if stats["statusCode"] >= 500:
             current["500"] += 1
+        elif stats["statusCode"] == 401:
+            current["401"] += 1
         current["t"] += stats.get("t", 0.0)
         current["t-resp-wr"] += stats.get("t-resp-wr", 0.0)
         current["slots"] += stats.get("outstandingRequests", 0)

Modified: CalendarServer/trunk/calendarserver/logAnalysis.py
===================================================================
--- CalendarServer/trunk/calendarserver/logAnalysis.py	2015-08-26 17:25:45 UTC (rev 15068)
+++ CalendarServer/trunk/calendarserver/logAnalysis.py	2015-08-26 18:01:05 UTC (rev 15069)
@@ -36,10 +36,12 @@
 METHOD_REPORT_CALENDAR_MULTIGET = "REPORT cal-multi"
 METHOD_REPORT_CALENDAR_QUERY = "REPORT cal-query"
 METHOD_REPORT_CALENDAR_FREEBUSY = "REPORT freebusy"
+METHOD_REPORT_CALENDAR_HOME_SYNC = "REPORT cal-home-sync"
 METHOD_REPORT_CALENDAR_SYNC = "REPORT cal-sync"
 METHOD_REPORT_ADDRESSBOOK_MULTIGET = "REPORT adbk-multi"
 METHOD_REPORT_ADDRESSBOOK_QUERY = "REPORT adbk-query"
 METHOD_REPORT_DIRECTORY_QUERY = "REPORT dir-query"
+METHOD_REPORT_ADDRESSBOOK_HOME_SYNC = "REPORT adbk-home-sync"
 METHOD_REPORT_ADDRESSBOOK_SYNC = "REPORT adbk-sync"
 METHOD_REPORT_P_SEARCH_P_SET = "REPORT p-set"
 METHOD_REPORT_P_P_SEARCH = "REPORT p-search"
@@ -48,9 +50,15 @@
 # POSTs
 METHOD_POST_CALENDAR_HOME = "POST Calendar Home"
 METHOD_POST_CALENDAR = "POST Calendar"
-METHOD_POST_CALENDAR_OBJECT = "POST Calendar Object"
+METHOD_POST_CALENDAR_ADD_MEMBER = "POST Calendar-add"
+METHOD_POST_CALENDAR_OBJECT = "POST ics"
+METHOD_POST_CALENDAR_OBJECT_SPLIT = "POST split"
+METHOD_POST_CALENDAR_OBJECT_ATTACHMENT_ADD = "POST att-add"
+METHOD_POST_CALENDAR_OBJECT_ATTACHMENT_UPDATE = "POST att-update"
+METHOD_POST_CALENDAR_OBJECT_ATTACHMENT_REMOVE = "POST att-remove"
 METHOD_POST_ADDRESSBOOK_HOME = "POST Adbk Home"
 METHOD_POST_ADDRESSBOOK = "POST Adbk"
+METHOD_POST_ADDRESSBOOK_ADD_MEMBER = "POST Adbk-add"
 METHOD_POST_ISCHEDULE_FREEBUSY = "POST Freebusy iSchedule"
 METHOD_POST_ISCHEDULE = "POST iSchedule"
 METHOD_POST_TIMEZONES = "POST Timezones"
@@ -89,12 +97,15 @@
 METHOD_DELETE_VCF = "DELETE vcf"
 
 
-def getAdjustedMethodName(stats):
+def getAdjustedMethodName(stats, method=None, uri=None):
 
-    method = stats["method"]
-    uribits = stats["uri"].rstrip("/").split('/')[1:]
+    if method is None:
+        method = stats["method"]
+    if uri is None:
+        uri = stats["uri"]
+    uribits = uri.rstrip("/").split('/')[1:]
     if len(uribits) == 0:
-        uribits = [stats["uri"]]
+        uribits = [uri]
 
     calendar_specials = ("attachments", "dropbox", "notification", "freebusy", "outbox",)
     adbk_specials = ("notification",)
@@ -143,17 +154,25 @@
                     report_type = "directory-query"
             if report_type == "sync-collection":
                 if uribits[0] == "calendars":
-                    report_type = "cal-sync"
+                    if len(uribits) == 3:
+                        report_type = "cal-home-sync"
+                    else:
+                        report_type = "cal-sync"
                 elif uribits[0] == "addressbooks":
-                    report_type = "adbk-sync"
+                    if len(uribits) == 3:
+                        report_type = "adbk-home-sync"
+                    else:
+                        report_type = "adbk-sync"
             mappedNames = {
                 "calendar-multiget"             : METHOD_REPORT_CALENDAR_MULTIGET,
                 "calendar-query"                : METHOD_REPORT_CALENDAR_QUERY,
                 "free-busy-query"               : METHOD_REPORT_CALENDAR_FREEBUSY,
+                "cal-home-sync"                 : METHOD_REPORT_CALENDAR_HOME_SYNC,
                 "cal-sync"                      : METHOD_REPORT_CALENDAR_SYNC,
                 "addressbook-multiget"          : METHOD_REPORT_ADDRESSBOOK_MULTIGET,
                 "addressbook-query"             : METHOD_REPORT_ADDRESSBOOK_QUERY,
                 "directory-query"               : METHOD_REPORT_DIRECTORY_QUERY,
+                "adbk-home-sync"                : METHOD_REPORT_ADDRESSBOOK_HOME_SYNC,
                 "adbk-sync"                     : METHOD_REPORT_ADDRESSBOOK_SYNC,
                 "principal-search-property-set" : METHOD_REPORT_P_SEARCH_P_SET,
                 "principal-property-search"     : METHOD_REPORT_P_P_SEARCH,
@@ -178,7 +197,18 @@
 
         if uribits[0] == "calendars":
 
-            if len(uribits) == 3:
+            if "(" in method:
+                post_type = method.split("(")[1][:-1]
+                mappedNames = {
+                    "add-member"            : METHOD_POST_CALENDAR_ADD_MEMBER,
+                    "split"                 : METHOD_POST_CALENDAR_OBJECT_SPLIT,
+                    "attachment-add"        : METHOD_POST_CALENDAR_OBJECT_ATTACHMENT_ADD,
+                    "attachment-update"     : METHOD_POST_CALENDAR_OBJECT_ATTACHMENT_UPDATE,
+                    "attachment-remove"     : METHOD_POST_CALENDAR_OBJECT_ATTACHMENT_REMOVE,
+                }
+                return mappedNames.get(post_type, "POST %s" % (post_type,))
+
+            elif len(uribits) == 3:
                 return METHOD_POST_CALENDAR_HOME
             elif len(uribits) == 4:
                 if uribits[3] == "outbox":
@@ -334,6 +364,7 @@
 
 osClients = (
     "Mac OS X/",
+    "Mac+OS+X/",
     "Mac_OS_X/",
     "iOS/",
 )

Modified: CalendarServer/trunk/calendarserver/tools/dashboard.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/dashboard.py	2015-08-26 17:25:45 UTC (rev 15068)
+++ CalendarServer/trunk/calendarserver/tools/dashboard.py	2015-08-26 18:01:05 UTC (rev 15069)
@@ -195,6 +195,7 @@
                         self.displayWindow(self.registered_windows["h"])
 
             self.resetWindows()
+
         # Reset the screen to the default config
         else:
             if self.windows:
@@ -209,15 +210,18 @@
                 self.windows.append(wtype(self.usesCurses, self.client).makeWindow(top=top))
                 self.windows[-1].activate()
                 top += self.windows[-1].nlines + 1
+
             # Don't display help panel if the window is too narrow
-            term_w, term_h = terminal_size()
-            logging.debug("logger displayWindow: rows: %s  cols: %s" % (term_h, term_w))
-            if int(term_w) > 100:
-                logging.debug('term_w > 100, making window with top at %d' % (top))
-                self.windows.append(HelpWindow(self.usesCurses, self.client).makeWindow(top=top))
-                self.windows[-1].activate()
+            if self.usesCurses:
+                term_w, term_h = terminal_size()
+                logging.debug("logger displayWindow: rows: %s  cols: %s" % (term_h, term_w))
+                if int(term_w) > 100:
+                    logging.debug('term_w > 100, making window with top at %d' % (top))
+                    self.windows.append(HelpWindow(self.usesCurses, self.client).makeWindow(top=top))
+                    self.windows[-1].activate()
 
-        curses.panel.update_panels()
+        if self.usesCurses:
+            curses.panel.update_panels()
         self.updateDisplay(True)
 
 
@@ -350,7 +354,8 @@
         Update the current data from the server.
         """
 
-        self.currentData = self.readSock(self.items)
+        # Only read each item once
+        self.currentData = self.readSock(list(set(self.items)))
 
 
     def getOneItem(self, item):
@@ -513,6 +518,9 @@
         x = 1
         y = 1
 
+        if not self.usesCurses:
+            print("------------ {}".format(self.title))
+
         items = []
         for keypress, wtype in sorted(
             Dashboard.registered_windows.items(), key=lambda x: x[0]
@@ -526,6 +534,9 @@
                 print(item)
             y += 1
 
+        if not self.usesCurses:
+            print("")
+
         if self.usesCurses:
             self.window.refresh()
 
@@ -574,6 +585,7 @@
             self.window.addstr(y, x, s1, curses.A_REVERSE)
             self.window.addstr(y + 1, x, s2, curses.A_REVERSE)
         else:
+            print("------------ {}".format(self.title))
             print(s1)
             print(s2)
         y += 2
@@ -633,6 +645,7 @@
             self.window.addstr(y, x, s)
         else:
             print(s)
+            print("")
         y += 1
 
         if self.usesCurses:
@@ -685,6 +698,7 @@
         if self.usesCurses:
             self.window.addstr(y, x, s, curses.A_REVERSE)
         else:
+            print("------------ {}".format(self.title))
             print(s)
         y += 1
         total_assigned = 0
@@ -727,6 +741,7 @@
             self.window.addstr(y, x, s)
         else:
             print(s)
+            print("")
         y += 1
 
         if self.usesCurses:
@@ -780,6 +795,7 @@
         if self.usesCurses:
             self.window.addstr(y, x, s, curses.A_REVERSE)
         else:
+            print("------------ {}".format(self.title))
             print(s)
         y += 1
         for record in sorted(records, key=lambda x: x["slot"]):
@@ -837,6 +853,7 @@
             if data["overloaded"]:
                 s += "    OVERLOADED"
             print(s)
+            print("")
         y += 1
 
         if self.usesCurses:
@@ -887,6 +904,7 @@
         if self.usesCurses:
             self.window.addstr(y, x, s, curses.A_REVERSE)
         else:
+            print("------------ {}".format(self.title))
             print(s)
         y += 1
 
@@ -917,6 +935,9 @@
                 pass
             y += 1
 
+        if not self.usesCurses:
+            print("")
+
         if self.usesCurses:
             self.window.refresh()
 
@@ -959,6 +980,7 @@
             self.window.addstr(y, x, s1, curses.A_REVERSE)
             self.window.addstr(y + 1, x, s2, curses.A_REVERSE)
         else:
+            print("------------ {}".format(self.title))
             print(s1)
             print(s2)
         y += 2
@@ -992,6 +1014,9 @@
                 pass
             y += 1
 
+        if not self.usesCurses:
+            print("")
+
         if self.usesCurses:
             self.window.refresh()
 
@@ -999,6 +1024,128 @@
 
 
 
+class MethodsWindow(BaseWindow):
+    """
+    Display the status of the server's request methods.
+    """
+
+    help = "server methods"
+    clientItem = "stats"
+    FORMAT_WIDTH = 116
+    stats_keys = ("current", "1m", "5m", "1h",)
+
+    def makeWindow(self, top=0, left=0):
+        stats = defaultIfNone(self.clientData(), {})
+        methods = set()
+        for key in self.stats_keys:
+            methods.update(stats.get(key, {}).get("method", {}).keys())
+        nlines = len(methods)
+        self.rowCount = nlines
+        self._createWindow("Methods", self.rowCount + 7, ncols=self.FORMAT_WIDTH, begin_y=top, begin_x=left)
+        return self
+
+
+    def update(self):
+        stats = defaultIfNone(self.clientData(), {})
+        methods = set()
+        for key in self.stats_keys:
+            methods.update(stats.get(key, {}).get("method", {}).keys())
+
+        records = {}
+        records_t = {}
+        for key in self.stats_keys:
+            records[key] = defaultIfNone(self.clientData(), {}).get(key, {}).get("method", {})
+            records_t[key] = defaultIfNone(self.clientData(), {}).get(key, {}).get("method-t", {})
+        self.iter += 1
+
+        if self.usesCurses:
+            self.window.erase()
+            self.window.border()
+            self.window.addstr(
+                0, 2,
+                self.title + " {} ({})".format(len(records), self.iter)
+            )
+
+        x = 1
+        y = 1
+        s1 = " {:<40}{:>8}{:>10}{:>8}{:>10}{:>8}{:>10}{:>8}{:>10} ".format(
+            "", "------", "current---", "------", "1m--------", "------", "5m--------", "------", "1h--------",
+        )
+        s2 = " {:<40}{:>8}{:>10}{:>8}{:>10}{:>8}{:>10}{:>8}{:>10} ".format(
+            "Method", "Number", "Av-Time", "Number", "Av-Time", "Number", "Av-Time", "Number", "Av-Time",
+        )
+        s3 = " {:<40}{:>8}{:>10}{:>8}{:>10}{:>8}{:>10}{:>8}{:>10} ".format(
+            "", "", "(ms)", "", "(ms)", "", "(ms)", "", "(ms)",
+        )
+        if self.usesCurses:
+            self.window.addstr(y, x, s1, curses.A_REVERSE)
+            self.window.addstr(y + 1, x, s2, curses.A_REVERSE)
+            self.window.addstr(y + 2, x, s3, curses.A_REVERSE)
+        else:
+            print("------------ {}".format(self.title))
+            print(s1)
+            print(s2)
+            print(s3)
+        y += 2
+        total_methods = dict([(key, 0) for key in self.stats_keys])
+        total_time = dict([(key, 0.0) for key in self.stats_keys])
+        for method_type in sorted(methods):
+            for key in self.stats_keys:
+                total_methods[key] += records[key].get(method_type, 0)
+                total_time[key] += records_t[key].get(method_type, 0.0)
+            changed = self.lastResult.get(method_type, 0) != records["current"].get(method_type, 0)
+            items = [method_type]
+            for key in self.stats_keys:
+                items.append(records[key].get(method_type, 0))
+                items.append(safeDivision(records_t[key].get(method_type, 0), records[key].get(method_type, 0)))
+            s = " {:<40}{:>8}{:>10.1f}{:>8}{:>10.1f}{:>8}{:>10.1f}{:>8}{:>10.1f} ".format(
+                *items
+            )
+            try:
+                if self.usesCurses:
+                    self.window.addstr(
+                        y, x, s,
+                        curses.A_REVERSE if changed else curses.A_NORMAL,
+                    )
+                else:
+                    print(s)
+            except curses.error:
+                pass
+            y += 1
+
+        items = ["Total:"]
+        for key in self.stats_keys:
+            items.append(total_methods[key])
+            items.append(safeDivision(total_time[key], total_methods[key]))
+        s1 = " {:<40}{:>8}{:>10.1f}{:>8}{:>10.1f}{:>8}{:>10.1f}{:>8}{:>10.1f} ".format(
+            *items
+        )
+        items = ["401s:"]
+        for key in self.stats_keys:
+            items.append(defaultIfNone(self.clientData(), {}).get(key, {}).get("401", 0))
+            items.append("")
+        s2 = " {:<40}{:>8}{:>10}{:>8}{:>10}{:>8}{:>10}{:>8}{:>10} ".format(
+            *items
+        )
+        if self.usesCurses:
+            self.window.hline(y, x, "-", self.FORMAT_WIDTH - 2)
+            y += 1
+            self.window.addstr(y, x, s1)
+            y += 1
+            self.window.addstr(y, x, s2)
+        else:
+            print(s1)
+            print(s2)
+            print("")
+        y += 1
+
+        if self.usesCurses:
+            self.window.refresh()
+
+        self.lastResult = defaultIfNone(self.clientData(), {}).get("current", {}).get("method", {})
+
+
+
 class DirectoryStatsWindow(BaseWindow):
     """
     Displays the status of the server's directory service calls
@@ -1044,6 +1191,7 @@
             self.window.addstr(y, x, s1, curses.A_REVERSE)
             self.window.addstr(y + 1, x, s2, curses.A_REVERSE)
         else:
+            print("------------ {}".format(self.title))
             print(s1)
             print(s2)
         y += 2
@@ -1111,6 +1259,7 @@
             print(s)
             print(s1)
             print(s2)
+            print("")
         y += 3
 
         if self.usesCurses:
@@ -1122,6 +1271,7 @@
 Dashboard.registerWindow(SystemWindow, "s")
 Dashboard.registerWindow(AssignmentsWindow, "w")
 Dashboard.registerWindow(RequestStatsWindow, "r")
+Dashboard.registerWindow(MethodsWindow, "m")
 Dashboard.registerWindow(JobsWindow, "j")
 Dashboard.registerWindow(HTTPSlotsWindow, "c")
 Dashboard.registerWindow(DirectoryStatsWindow, "d")

Modified: CalendarServer/trunk/contrib/tools/protocolanalysis.py
===================================================================
--- CalendarServer/trunk/contrib/tools/protocolanalysis.py	2015-08-26 17:25:45 UTC (rev 15068)
+++ CalendarServer/trunk/contrib/tools/protocolanalysis.py	2015-08-26 18:01:05 UTC (rev 15069)
@@ -26,6 +26,13 @@
 import tables
 import traceback
 import glob
+from calendarserver.logAnalysis import getAdjustedMethodName, METHOD_PUT_ICS, \
+    METHOD_PUT_ORGANIZER, METHOD_PUT_ATTENDEE, METHOD_PROPFIND_CALENDAR, \
+    METHOD_POST_FREEBUSY, METHOD_POST_ORGANIZER, METHOD_POST_ISCHEDULE_FREEBUSY, \
+    METHOD_POST_ISCHEDULE, METHOD_GET_DROPBOX, METHOD_PROPFIND_CALENDAR_HOME, \
+    METHOD_PROPFIND_CACHED_CALENDAR_HOME, METHOD_PROPFIND_ADDRESSBOOK_HOME, \
+    METHOD_PROPFIND_CACHED_ADDRESSBOOK_HOME, METHOD_PROPFIND_PRINCIPALS, \
+    METHOD_PROPFIND_CACHED_PRINCIPALS
 
 def safePercent(x, y, multiplier=100):
     return ((multiplier * x) / y) if y else 0
@@ -114,79 +121,6 @@
     "SEARCH",
 ))
 
-# Adjust method names
-
-# PROPFINDs
-METHOD_PROPFIND_CALENDAR_HOME = "PROPFIND Calendar Home"
-METHOD_PROPFIND_CACHED_CALENDAR_HOME = "PROPFIND cached Calendar Home"
-METHOD_PROPFIND_CALENDAR = "PROPFIND Calendar"
-METHOD_PROPFIND_INBOX = "PROPFIND Inbox"
-METHOD_PROPFIND_ADDRESSBOOK_HOME = "PROPFIND Adbk Home"
-METHOD_PROPFIND_CACHED_ADDRESSBOOK_HOME = "PROPFIND cached Adbk Home"
-METHOD_PROPFIND_ADDRESSBOOK = "PROPFIND Adbk"
-METHOD_PROPFIND_DIRECTORY = "PROPFIND Directory"
-METHOD_PROPFIND_PRINCIPALS = "PROPFIND Principals"
-METHOD_PROPFIND_CACHED_PRINCIPALS = "PROPFIND cached Principals"
-
-# PROPPATCHs
-METHOD_PROPPATCH_CALENDAR = "PROPPATCH Calendar"
-METHOD_PROPPATCH_ADDRESSBOOK = "PROPPATCH Adbk Home"
-
-# REPORTs
-METHOD_REPORT_CALENDAR_MULTIGET = "REPORT cal-multi"
-METHOD_REPORT_CALENDAR_QUERY = "REPORT cal-query"
-METHOD_REPORT_CALENDAR_FREEBUSY = "REPORT freebusy"
-METHOD_REPORT_CALENDAR_SYNC = "REPORT cal-sync"
-METHOD_REPORT_ADDRESSBOOK_MULTIGET = "REPORT adbk-multi"
-METHOD_REPORT_ADDRESSBOOK_QUERY = "REPORT adbk-query"
-METHOD_REPORT_DIRECTORY_QUERY = "REPORT dir-query"
-METHOD_REPORT_ADDRESSBOOK_SYNC = "REPORT adbk-sync"
-METHOD_REPORT_P_SEARCH_P_SET = "REPORT p-set"
-METHOD_REPORT_P_P_SEARCH = "REPORT p-search"
-METHOD_REPORT_EXPAND_P = "REPORT expand"
-
-# POSTs
-METHOD_POST_CALENDAR_HOME = "POST Calendar Home"
-METHOD_POST_CALENDAR = "POST Calendar"
-METHOD_POST_ADDRESSBOOK_HOME = "POST Adbk Home"
-METHOD_POST_ADDRESSBOOK = "POST Adbk"
-METHOD_POST_ISCHEDULE_FREEBUSY = "POST Freebusy iSchedule"
-METHOD_POST_ISCHEDULE = "POST iSchedule"
-METHOD_POST_TIMEZONES = "POST Timezones"
-METHOD_POST_FREEBUSY = "POST Freebusy"
-METHOD_POST_ORGANIZER = "POST Organizer"
-METHOD_POST_ATTENDEE = "POST Attendee"
-METHOD_POST_OUTBOX = "POST Outbox"
-METHOD_POST_APNS = "POST apns"
-
-# PUTs
-METHOD_PUT_ICS = "PUT ics"
-METHOD_PUT_ORGANIZER = "PUT Organizer"
-METHOD_PUT_ATTENDEE = "PUT Attendee"
-METHOD_PUT_DROPBOX = "PUT dropbox"
-METHOD_PUT_VCF = "PUT VCF"
-
-# GETs
-METHOD_GET_CALENDAR_HOME = "GET Calendar Home"
-METHOD_GET_CALENDAR = "GET Calendar"
-METHOD_GET_ICS = "GET ics"
-METHOD_GET_INBOX_ICS = "GET inbox ics"
-METHOD_GET_DROPBOX = "GET dropbox"
-METHOD_GET_ADDRESSBOOK_HOME = "GET Adbk Home"
-METHOD_GET_ADDRESSBOOK = "GET Adbk"
-METHOD_GET_VCF = "GET VCF"
-METHOD_GET_TIMEZONES = "GET Timezones"
-
-# DELETEs
-METHOD_DELETE_CALENDAR_HOME = "DELETE Calendar Home"
-METHOD_DELETE_CALENDAR = "DELETE Calendar"
-METHOD_DELETE_ICS = "DELETE ics"
-METHOD_DELETE_INBOX_ICS = "DELETE inbox ics"
-METHOD_DELETE_DROPBOX = "DELETE dropbox"
-METHOD_DELETE_ADDRESSBOOK_HOME = "DELETE Adbk Home"
-METHOD_DELETE_ADDRESSBOOK = "DELETE Adbk"
-METHOD_DELETE_VCF = "DELETE vcf"
-
 # 401s
 METHOD_401 = "Z 401s"
 
@@ -332,7 +266,7 @@
                     continue
 
                 # Filter method
-                if self.ignoreNonHTTPMethods and not self.currentLine.method.startswith("REPORT(") and self.currentLine.method not in httpMethods:
+                if self.ignoreNonHTTPMethods and not self.currentLine.method.startswith("REPORT(") and not self.currentLine.method.startswith("POST(") and self.currentLine.method not in httpMethods:
                     self.currentLine.method = "???"
 
                 # Do hour ranges
@@ -674,213 +608,9 @@
 
 
     def getAdjustedMethodName(self):
+        return getAdjustedMethodName(self.currentLine.extended, self.currentLine.method, self.currentLine.uri)
 
-        uribits = self.currentLine.uri.rstrip("/").split('/')[1:]
-        if len(uribits) == 0:
-            uribits = [self.currentLine.uri]
 
-        calendar_specials = ("dropbox", "notification", "freebusy", "outbox",)
-        adbk_specials = ("notification",)
-
-        if self.currentLine.method == "PROPFIND":
-
-            cached = "cached" in self.currentLine.extended
-
-            if uribits[0] == "calendars":
-
-                if len(uribits) == 3:
-                    return METHOD_PROPFIND_CACHED_CALENDAR_HOME if cached else METHOD_PROPFIND_CALENDAR_HOME
-                elif len(uribits) > 3:
-                    if uribits[3] in calendar_specials:
-                        return "PROPFIND %s" % (uribits[3],)
-                    elif len(uribits) == 4:
-                        if uribits[3] == "inbox":
-                            return METHOD_PROPFIND_INBOX
-                        else:
-                            return METHOD_PROPFIND_CALENDAR
-
-            elif uribits[0] == "addressbooks":
-
-                if len(uribits) == 3:
-                    return METHOD_PROPFIND_CACHED_ADDRESSBOOK_HOME if cached else METHOD_PROPFIND_ADDRESSBOOK_HOME
-                elif len(uribits) > 3:
-                    if uribits[3] in adbk_specials:
-                        return "PROPFIND %s" % (uribits[3],)
-                    elif len(uribits) == 4:
-                        return METHOD_PROPFIND_ADDRESSBOOK
-
-            elif uribits[0] == "directory":
-                return METHOD_PROPFIND_DIRECTORY
-
-            elif uribits[0] == "principals":
-                return METHOD_PROPFIND_CACHED_PRINCIPALS if cached else METHOD_PROPFIND_PRINCIPALS
-
-        elif self.currentLine.method.startswith("REPORT"):
-
-            if "(" in self.currentLine.method:
-                report_type = self.currentLine.method.split("}" if "}" in self.currentLine.method else ":")[1][:-1]
-                if report_type == "addressbook-query":
-                    if uribits[0] == "directory":
-                        report_type = "directory-query"
-                if report_type == "sync-collection":
-                    if uribits[0] == "calendars":
-                        report_type = "cal-sync"
-                    elif uribits[0] == "addressbooks":
-                        report_type = "adbk-sync"
-                mappedNames = {
-                    "calendar-multiget"             : METHOD_REPORT_CALENDAR_MULTIGET,
-                    "calendar-query"                : METHOD_REPORT_CALENDAR_QUERY,
-                    "free-busy-query"               : METHOD_REPORT_CALENDAR_FREEBUSY,
-                    "cal-sync"                      : METHOD_REPORT_CALENDAR_SYNC,
-                    "addressbook-multiget"          : METHOD_REPORT_ADDRESSBOOK_MULTIGET,
-                    "addressbook-query"             : METHOD_REPORT_ADDRESSBOOK_QUERY,
-                    "directory-query"               : METHOD_REPORT_DIRECTORY_QUERY,
-                    "adbk-sync"                     : METHOD_REPORT_ADDRESSBOOK_SYNC,
-                    "principal-search-property-set" : METHOD_REPORT_P_SEARCH_P_SET,
-                    "principal-property-search"     : METHOD_REPORT_P_P_SEARCH,
-                    "expand-property"               : METHOD_REPORT_EXPAND_P,
-                }
-                return mappedNames.get(report_type, "REPORT %s" % (report_type,))
-
-        elif self.currentLine.method == "PROPPATCH":
-
-            if uribits[0] == "calendars":
-                return METHOD_PROPPATCH_CALENDAR
-            elif uribits[0] == "addressbooks":
-                return METHOD_PROPPATCH_ADDRESSBOOK
-
-        elif self.currentLine.method == "POST":
-
-            if uribits[0] == "calendars":
-
-                if len(uribits) == 3:
-                    return METHOD_POST_CALENDAR_HOME
-                elif len(uribits) == 4:
-                    if uribits[3] == "outbox":
-                        if "recipients" in self.currentLine.extended:
-                            return METHOD_POST_FREEBUSY
-                        elif "freebusy" in self.currentLine.extended:
-                            return METHOD_POST_FREEBUSY
-                        elif "itip.request" in self.currentLine.extended or "itip.cancel" in self.currentLine.extended:
-                            return METHOD_POST_ORGANIZER
-                        elif "itip.reply" in self.currentLine.extended:
-                            return METHOD_POST_ATTENDEE
-                        else:
-                            return METHOD_POST_OUTBOX
-                    elif uribits[3] in calendar_specials:
-                        pass
-                    else:
-                        return METHOD_POST_CALENDAR
-
-            elif uribits[0] == "addressbooks":
-
-                if len(uribits) == 3:
-                    return METHOD_POST_ADDRESSBOOK_HOME
-                elif len(uribits) == 4:
-                    if uribits[3] in adbk_specials:
-                        pass
-                    else:
-                        return METHOD_POST_ADDRESSBOOK
-
-            elif uribits[0] == "ischedule":
-                if "fb-cached" in self.currentLine.extended or "fb-uncached" in self.currentLine.extended or "freebusy" in self.currentLine.extended:
-                    return METHOD_POST_ISCHEDULE_FREEBUSY
-                else:
-                    return METHOD_POST_ISCHEDULE
-
-            elif uribits[0].startswith("timezones"):
-                return METHOD_POST_TIMEZONES
-
-            elif uribits[0].startswith("apns"):
-                return METHOD_POST_APNS
-
-        elif self.currentLine.method == "PUT":
-
-            if uribits[0] == "calendars":
-                if len(uribits) > 3:
-                    if uribits[3] in calendar_specials:
-                        return "PUT %s" % (uribits[3],)
-                    elif len(uribits) == 4:
-                        pass
-                    else:
-                        if "itip.requests" in self.currentLine.extended:
-                            return METHOD_PUT_ORGANIZER
-                        elif "itip.reply" in self.currentLine.extended:
-                            return METHOD_PUT_ATTENDEE
-                        else:
-                            return METHOD_PUT_ICS
-
-            elif uribits[0] == "addressbooks":
-                if len(uribits) > 3:
-                    if uribits[3] in adbk_specials:
-                        return "PUT %s" % (uribits[3],)
-                    elif len(uribits) == 4:
-                        pass
-                    else:
-                        return METHOD_PUT_VCF
-
-        elif self.currentLine.method == "GET":
-
-            if uribits[0] == "calendars":
-
-                if len(uribits) == 3:
-                    return METHOD_GET_CALENDAR_HOME
-                elif len(uribits) > 3:
-                    if uribits[3] in calendar_specials:
-                        return "GET %s" % (uribits[3],)
-                    elif len(uribits) == 4:
-                        return METHOD_GET_CALENDAR
-                    elif uribits[3] == "inbox":
-                        return METHOD_GET_INBOX_ICS
-                    else:
-                        return METHOD_GET_ICS
-
-            elif uribits[0] == "addressbooks":
-
-                if len(uribits) == 3:
-                    return METHOD_GET_ADDRESSBOOK_HOME
-                elif len(uribits) > 3:
-                    if uribits[3] in adbk_specials:
-                        return "GET %s" % (uribits[3],)
-                    elif len(uribits) == 4:
-                        return METHOD_GET_ADDRESSBOOK
-                    else:
-                        return METHOD_GET_VCF
-
-            elif uribits[0].startswith("timezones"):
-                return METHOD_GET_TIMEZONES
-
-        elif self.currentLine.method == "DELETE":
-
-            if uribits[0] == "calendars":
-
-                if len(uribits) == 3:
-                    return METHOD_DELETE_CALENDAR_HOME
-                elif len(uribits) > 3:
-                    if uribits[3] in calendar_specials:
-                        return "DELETE %s" % (uribits[3],)
-                    elif len(uribits) == 4:
-                        return METHOD_DELETE_CALENDAR
-                    elif uribits[3] == "inbox":
-                        return METHOD_DELETE_INBOX_ICS
-                    else:
-                        return METHOD_DELETE_ICS
-
-            elif uribits[0] == "addressbooks":
-
-                if len(uribits) == 3:
-                    return METHOD_DELETE_ADDRESSBOOK_HOME
-                elif len(uribits) > 3:
-                    if uribits[3] in adbk_specials:
-                        return "DELETE %s" % (uribits[3],)
-                    elif len(uribits) == 4:
-                        return METHOD_DELETE_ADDRESSBOOK
-                    else:
-                        return METHOD_DELETE_VCF
-
-        return self.currentLine.method
-
-
     def getCountBucket(self, count, buckets):
 
         for limit, key in buckets:

Modified: CalendarServer/trunk/twistedcaldav/method/post.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/post.py	2015-08-26 17:25:45 UTC (rev 15068)
+++ CalendarServer/trunk/twistedcaldav/method/post.py	2015-08-26 18:01:05 UTC (rev 15069)
@@ -36,6 +36,7 @@
     if request.params:
         if request.params == "add-member":
             if config.EnableAddMember and hasattr(self, "POST_handler_add_member"):
+                request.submethod = "add-member"
                 result = (yield self.POST_handler_add_member(request))
                 returnValue(result)
 
@@ -45,6 +46,7 @@
         if len(action) == 1:
             action = action[0]
             if hasattr(self, "POST_handler_action"):
+                request.submethod = action
                 result = (yield self.POST_handler_action(request, action))
                 returnValue(result)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150826/022feb0d/attachment-0001.html>


More information about the calendarserver-changes mailing list