[CalendarServer-changes] [4848] CalendarServer/branches/users/wsanchez/deployment/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Wed Dec 9 15:37:18 PST 2009


Revision: 4848
          http://trac.macosforge.org/projects/calendarserver/changeset/4848
Author:   wsanchez at apple.com
Date:     2009-12-09 15:37:16 -0800 (Wed, 09 Dec 2009)
Log Message:
-----------
add config.MaxAllowedInstances

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/config.py
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/instance.py

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/config.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/config.py	2009-12-09 17:07:53 UTC (rev 4847)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/config.py	2009-12-09 23:37:16 UTC (rev 4848)
@@ -272,6 +272,7 @@
     "IdleConnectionTimeOut": 15,
     "UIDReservationTimeOut": 30 * 60,
 
+    "MaxAllowedInstances": 3000,
 
     #
     # Localization

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/instance.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/instance.py	2009-12-09 17:07:53 UTC (rev 4847)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/instance.py	2009-12-09 23:37:16 UTC (rev 4848)
@@ -20,22 +20,18 @@
 
 import datetime
 
+from twistedcaldav.config import config
 from twistedcaldav.dateops import normalizeForIndex, compareDateTime, differenceDateTime, periodEnd
 
 from vobject.icalendar import utc
 
-# The maximum number of instances we will expand out to.
-# Raise a TooManyInstancesError exception if we exceed this.
-max_allowed_instances = 3000
+class TooManyInstancesError(RuntimeError):
+    def __init__(self, count):
+        RuntimeError.__init__(self, "Too many recurrance instances (%s > %s)"
+                              % (count, config.MaxAllowedInstances))
+        self.count = count
+        self.max_allowed = config.MaxAllowedInstances
 
-class TooManyInstancesError(Exception):
-    def __init__(self):
-        Exception.__init__(self)
-        self.max_allowed = max_allowed_instances
-
-    def __repr__(self):
-        return "<%s max:%s>" % (self.__class__.__name__, self.max_allowed)
-
 class Instance(object):
     
     __slots__ = ["component", "start", "end", "rid", "overridden", "future"]
@@ -162,8 +158,8 @@
         self.instances[str(instance.rid)] = instance
         
         # Check for too many instances
-        if len(self.instances) > max_allowed_instances:
-            raise TooManyInstancesError()
+        if len(self.instances) > config.MaxAllowedInstances:
+            raise TooManyInstancesError(len(self.instances))
 
     def _addMasterEventComponent(self, component, limit):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20091209/33777a2d/attachment-0001.html>


More information about the calendarserver-changes mailing list