[CalendarServer-changes] [4523] CalendarServer/branches/users/wsanchez/deployment-submit

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 2 10:57:11 PDT 2009


Revision: 4523
          http://trac.macosforge.org/projects/calendarserver/changeset/4523
Author:   cdaboo at apple.com
Date:     2009-09-02 10:57:11 -0700 (Wed, 02 Sep 2009)
Log Message:
-----------
Undo r4516 in this branch.

Revision Links:
--------------
    http://trac.macosforge.org/projects/calendarserver/changeset/4516

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/deployment-submit/conf/caldavd-test.plist
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/accesslog.py
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/config.py
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/extensions.py
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/httpfactory.py
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/propfind.py
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report.py
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report_calquery.py
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report_multiget.py
    CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/schedule.py

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/conf/caldavd-test.plist
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/conf/caldavd-test.plist	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/conf/caldavd-test.plist	2009-09-02 17:57:11 UTC (rev 4523)
@@ -285,6 +285,8 @@
    <string>debug</string>
  -->
   </dict>
+	<key>MoreAccessLogData</key>
+	<true/>
 
   <!-- Accounting -->
   <key>AccountingCategories</key>

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/accesslog.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/accesslog.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/accesslog.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -64,6 +64,10 @@
             request = eventDict['request']
             response = eventDict['response']
             loginfo = eventDict['loginfo']
+            firstLine = '%s %s HTTP/%s' %(
+                request.method,
+                request.uri.replace('"', '%22'),
+                '.'.join([str(x) for x in request.clientproto]))
     
             # Try to determine authentication and authorization identifiers
             uid = "-"
@@ -95,75 +99,46 @@
                     else:
                         uid = uidn
     
-            #
-            # For some methods which basically allow you to tunnel a
-            # custom request (eg. REPORT, POST), the method name
-            # itself doesn't tell you much about what action is being
-            # requested.  This allows a method to tack a submethod
-            # attribute to the request, so we can provide a little
-            # more detail here.
-            #
-            if config.EnableExtendedAccessLog and hasattr(request, "submethod"):
-                method = "%s(%s)" % (request.method, request.submethod)
-            else:
-                method = request.method
-
-            # Standard Apache access log fields
-            format = (
-                '%(host)s - %(uid)s [%(date)s]'
-                ' "%(method)s %(uri)s HTTP/%(protocolVersion)s"'
-                ' %(statusCode)s %(bytesSent)d'
-                ' "%(referer)s" "%(userAgent)s"'
+            format_str = '%s - %s [%s] "%s" %s %d "%s" "%s" [%.1f ms]'
+            format_data = (
+                request.remoteAddr.host,
+                uid,
+                self.logDateString(
+                    response.headers.getHeader('date', 0)),
+                firstLine,
+                response.code,
+                loginfo.bytesSent,
+                request.headers.getHeader('referer', '-'),
+                request.headers.getHeader('user-agent', '-'),
+                (time.time() - request.initTime) * 1000,
             )
-
-            try:
-                serverInstance = request.chanRequest.transport.server.port
-            except AttributeError:
-                serverInstance = "Unknown"
-            if config.EnableExtendedAccessLog:
+            if config.MoreAccessLogData:
+                try:
+                    serverInstance = request.chanRequest.transport.server.port
+                except AttributeError:
+                    serverInstance = "Unknown"
                 
-                formats = [
-                    format,
-                    # Performance monitoring extensions
-                    'i=%(serverInstance)s t=%(timeSpent).1f or=%(outstandingRequests)s',
-                ]
-                if hasattr(request, "extendedLogItems"):
-                    for k, v in request.extendedLogItems.iteritems():
-                        v = str(v).replace('"', "%22")
-                        if " " in v:
-                            v = '"%s"' % (v,)
-                        formats.append("%s=%s" % (k, v))
-                format = " ".join(formats)
+                format_str += ' [%s %s]'
+                format_data += (
+                    serverInstance,
+                    request.chanRequest.channel.factory.outstandingRequests,
+                )
+            self.logMessage(format_str % format_data)
 
-            formatArgs = {
-                "host"                : request.remoteAddr.host,
-                "uid"                 : uid,
-                "date"                : self.logDateString(response.headers.getHeader("date", 0)),
-                "method"              : method,
-                "uri"                 : request.uri.replace('"', "%22"),
-                "protocolVersion"     : ".".join(str(x) for x in request.clientproto),
-                "statusCode"          : response.code,
-                "bytesSent"           : loginfo.bytesSent,
-                "referer"             : request.headers.getHeader("referer", "-"),
-                "userAgent"           : request.headers.getHeader("user-agent", "-"),
-                "serverInstance"      : serverInstance,
-                "timeSpent"           : (time.time() - request.initTime) * 1000,
-                "outstandingRequests" : request.chanRequest.channel.factory.outstandingRequests,
-            }
-            self.logMessage(format % formatArgs)
-
         elif "overloaded" in eventDict:
             overloaded = eventDict.get("overloaded")
-            format = '%(host)s - - [%(date)s] "???" 503 0 "-" "-"'
-            formatArgs = {
-                "host": overloaded.transport.hostname,
-                "date": self.logDateString(time.time()),
-            }
-            if config.EnableExtendedAccessLog:
-                format += " i=%(serverInstance)s t=0.0 or=%(outstandingRequests)s"
-                formatArgs["serverInstance"] = overloaded.transport.server.port
-                formatArgs["outstandingRequests"] = overloaded.outstandingRequests
-            self.logMessage(format % formatArgs)
+            format_str = '%s - - [%s] "???" 503 0 "-" "-" [0.0 ms]'
+            format_data = (
+                overloaded.transport.hostname,
+                self.logDateString(time.time()),
+            )
+            if config.MoreAccessLogData:
+                format_str += ' [%s %s]'
+                format_data += (
+                    overloaded.transport.server.port,
+                    overloaded.outstandingRequests,
+                )
+            self.logMessage(format_str % format_data)
 
 class RotatingFileAccessLoggingObserver(CommonAccessLoggingObserverExtensions):
     """

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/config.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/config.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/config.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -164,8 +164,8 @@
     "ErrorLogFile"   : "/var/log/caldavd/error.log",   # Server activity log
     "ServerStatsFile": "/var/run/caldavd/stats.plist",
     "PIDFile"        : "/var/run/caldavd.pid",
-    "RotateAccessLog"         : False,
-    "EnableExtendedAccessLog" : True,
+    "RotateAccessLog"   : False,
+    "MoreAccessLogData" : True,
     "DefaultLogLevel"   : "",
     "LogLevels"         : {},
 

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/extensions.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/extensions.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/extensions.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -52,7 +52,6 @@
 from twistedcaldav.util import submodule, Alternator, printTracebacks
 from twistedcaldav.directory.sudo import SudoDirectoryService
 from twistedcaldav.directory.directory import DirectoryService
-from twistedcaldav.method.report import http_REPORT
 
 log = Logger()
 
@@ -222,7 +221,6 @@
     def http_ACL(self, request):
         return super(DAVResource, self).http_ACL(request)
 
-    http_REPORT = http_REPORT 
 
     def findChildrenFaster(self, depth, request, okcallback, badcallback, names, privileges, inherited_aces):
         """
@@ -424,9 +422,6 @@
     """
     Extended L{twisted.web2.dav.static.DAVFile} implementation.
     """
-
-    http_REPORT = http_REPORT
-
     def readProperty(self, property, request):
         if type(property) is tuple:
             qname = property

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/httpfactory.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/httpfactory.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/httpfactory.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -30,7 +30,8 @@
         self.outstandingRequests = outstandingRequests
 
     def connectionMade(self):
-        log.msg(overloaded=self)
+        if config.MoreAccessLogData:
+            log.msg(overloaded=self)
 
         retryAfter = randint(int(config.HTTPRetryAfter * 1/2), int(config.HTTPRetryAfter * 3/2))
 

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/propfind.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/propfind.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/propfind.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -193,10 +193,6 @@
 
         xml_responses.append(xml_response)
 
-    if not hasattr(request, "extendedLogItems"):
-        request.extendedLogItems = {}
-    request.extendedLogItems["responses"] = len(xml_responses)
-
     #
     # Return response
     #

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -78,22 +78,7 @@
     namespace = doc.root_element.namespace
     name = doc.root_element.name
 
-    if namespace:
-        if namespace == davxml.dav_namespace:
-            request.submethod = "DAV:" + name
-        elif namespace == caldavxml.caldav_namespace:
-            request.submethod = "CalDAV:" + name
-        else:
-            request.submethod = "{%s}%s" % (namespace, name)
-    else:
-        request.submethod = name
-
-    def to_method(namespace, name):
-        if namespace:
-            s = "_".join((namespace, name))
-        else:
-            s = name
-
+    def to_method(s):
         ok = string.ascii_letters + string.digits + "_"
         out = []
         for c in s:
@@ -103,7 +88,10 @@
                 out.append("_")
         return "report_" + "".join(out)
 
-    method_name = to_method(namespace, name)
+    if namespace:
+        method_name = to_method(namespace + "_" + name)
+    else:
+        method_name = to_method(name)
 
     try:
         method = getattr(self, method_name)

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report_calquery.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report_calquery.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report_calquery.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -252,10 +252,6 @@
         log.err("Too many matching components in calendar-query report")
         raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (dav_namespace, "number-of-matches-within-limits")))
     
-    if not hasattr(request, "extendedLogItems"):
-        request.extendedLogItems = {}
-    request.extendedLogItems["responses"] = len(responses)
-
     yield MultiStatusResponse(responses)
 
 report_urn_ietf_params_xml_ns_caldav_calendar_query = deferredGenerator(report_urn_ietf_params_xml_ns_caldav_calendar_query)

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report_multiget.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report_multiget.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/method/report_multiget.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -61,16 +61,7 @@
 
     propertyreq = multiget.property
     resources  = multiget.resources
-
-    if not hasattr(request, "extendedLogItems"):
-        request.extendedLogItems = {}
-    request.extendedLogItems["rcount"] = len(resources)
     
-    # Check size of results is within limit
-    if len(resources) > max_number_of_multigets:
-        log.err("Too many results in multiget report: %d" % len(resources))
-        raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, davxml.NumberOfMatchesWithinLimits()))
-
     if propertyreq.qname() == ("DAV:", "allprop"):
         propertiesForResource = report_common.allPropertiesForResource
 
@@ -88,6 +79,11 @@
     else:
         raise AssertionError("We shouldn't be here")
 
+    # Check size of results is within limit
+    if len(resources) > max_number_of_multigets:
+        log.err("Too many results in multiget report: %d" % len(resources))
+        raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (dav_namespace, "number-of-matches-within-limits")))
+
     """
     Three possibilities exist:
         

Modified: CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/schedule.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/schedule.py	2009-09-02 14:23:02 UTC (rev 4522)
+++ CalendarServer/branches/users/wsanchez/deployment-submit/twistedcaldav/schedule.py	2009-09-02 17:57:11 UTC (rev 4523)
@@ -415,8 +415,6 @@
         # shows up in a given principal's calendars, rather than
         # tracking the activities of a specific user.
         #
-        if not hasattr(request, "extendedLogItems"):
-            request.extendedLogItems = {}
         if freebusy:
             if accountingEnabled("iTIP-VFREEBUSY", organizerPrincipal):
                 emitAccounting(
@@ -424,8 +422,6 @@
                     "Originator: %s\nRecipients: %s\n\n%s"
                     % (originator, ", ".join(recipients), str(calendar))
                 )
-            request.extendedLogItems["freebusy"] = len(recipients)
-    
         else:
             if accountingEnabled("iTIP", organizerPrincipal):
                 emitAccounting(
@@ -433,7 +429,6 @@
                     "Originator: %s\nRecipients: %s\n\n%s"
                     % (originator, ", ".join(recipients), str(calendar))
                 )
-            request.extendedLogItems["itip.%s" % (calendar.propertyValue("METHOD").lower(),)] = len(recipients)
 
         # Prepare for multiple responses
         responses = ScheduleResponseQueue("POST", responsecode.OK)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090902/e2c33dfd/attachment-0001.html>


More information about the calendarserver-changes mailing list