[CalendarServer-changes] [7326] CalendarServer/branches/users/cdaboo/pods
source_changes at macosforge.org
source_changes at macosforge.org
Tue Apr 19 13:43:41 PDT 2011
Revision: 7326
http://trac.macosforge.org/projects/calendarserver/changeset/7326
Author: cdaboo at apple.com
Date: 2011-04-19 13:43:41 -0700 (Tue, 19 Apr 2011)
Log Message:
-----------
Fixes to work wit deployment-style iSchedule server.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/pods/conf/servers.dtd
CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/directory.py
CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/principal.py
CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/ischedule.py
CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py
CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py
Modified: CalendarServer/branches/users/cdaboo/pods/conf/servers.dtd
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/conf/servers.dtd 2011-04-19 20:03:13 UTC (rev 7325)
+++ CalendarServer/branches/users/cdaboo/pods/conf/servers.dtd 2011-04-19 20:43:41 UTC (rev 7326)
@@ -17,6 +17,7 @@
<!ELEMENT servers (server*) >
<!ELEMENT server (id, uri, partitions?) >
+ <!ATTLIST server implicit (yes|no) "yes">
<!ELEMENT id (#PCDATA) >
<!ELEMENT uri (#PCDATA) >
Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/directory.py 2011-04-19 20:03:13 UTC (rev 7325)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/directory.py 2011-04-19 20:43:41 UTC (rev 7326)
@@ -509,6 +509,15 @@
else:
return None
+ def server(self):
+ """
+ Server hosting this record. Return None if hosted on this server.
+ """
+ if config.Servers.Enabled and self.serverID:
+ return servers.Servers.getServerById(self.serverID)
+ else:
+ return None
+
def partitionURI(self):
"""
URL of the server hosting this record. Return None if hosted on this server.
Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/principal.py 2011-04-19 20:03:13 UTC (rev 7325)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/principal.py 2011-04-19 20:43:41 UTC (rev 7326)
@@ -771,6 +771,9 @@
def serverURI(self):
return self.record.serverURI()
+ def server(self):
+ return self.record.server()
+
def partitionURI(self):
return self.record.partitionURI()
Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/ischedule.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/ischedule.py 2011-04-19 20:03:13 UTC (rev 7325)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/ischedule.py 2011-04-19 20:43:41 UTC (rev 7326)
@@ -146,12 +146,12 @@
if not hasattr(self, "otherServers"):
self.otherServers = {}
- server = recipient.principal.serverURI()
- if server not in self.otherServers:
- self.otherServers[server] = IScheduleServerRecord(uri=joinURL(server, "/ischedule"))
- self.otherServers[server].unNormalizeAddresses = False
+ serverURI = recipient.principal.serverURI()
+ if serverURI not in self.otherServers:
+ self.otherServers[serverURI] = IScheduleServerRecord(uri=joinURL(serverURI, "/ischedule"))
+ self.otherServers[serverURI].unNormalizeAddresses = not recipient.principal.server().isImplicit
- return self.otherServers[server]
+ return self.otherServers[serverURI]
class IScheduleRequest(object):
Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py 2011-04-19 20:03:13 UTC (rev 7325)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py 2011-04-19 20:43:41 UTC (rev 7326)
@@ -19,6 +19,7 @@
import socket
import urlparse
+from twisted.internet.abstract import isIPAddress
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.python.failure import Failure
@@ -263,6 +264,8 @@
# Parse the calendar object from the HTTP request stream
try:
self.calendar = (yield Component.fromIStream(self.request.stream))
+
+ self.preProcessCalendarData()
self.calendardata = str(self.calendar)
except:
# FIXME: Bare except
@@ -273,6 +276,13 @@
description="Can't parse calendar data"
))
+ def preProcessCalendarData(self):
+ """
+ After loading calendar data from the request, do some optional processing of it. This method will be
+ overridden by those schedulers that need to do special things to the data.
+ """
+ pass
+
def checkAuthorization(self):
raise NotImplementedError
@@ -812,6 +822,25 @@
if self.request.headers.getRawHeaders('x-calendarserver-itip-refreshonly', ("F"))[0] == "T":
self.request.doing_attendee_refresh = 1
+ def preProcessCalendarData(self):
+ """
+ For data coming in from outside we need to normalize the calendar user addresses so that later iTIP
+ processing will match calendar users against those in stored calendar data.
+ """
+
+ def lookupFunction(cuaddr):
+ principal = self.resource.principalForCalendarUserAddress(cuaddr)
+ if principal is None:
+ return (None, None, None)
+ else:
+ return (
+ principal.record.fullName.decode("utf-8"),
+ principal.record.guid,
+ principal.record.calendarUserAddresses
+ )
+
+ self.calendar.normalizeCalendarUserAddresses(lookupFunction)
+
def checkAuthorization(self):
# Must have an unauthenticated user
if self.resource.currentPrincipal(self.request) != davxml.Principal(davxml.Unauthenticated()):
@@ -919,20 +948,21 @@
# First compare as dotted IP
matched = False
- if clientip == expected_uri.hostname:
- matched = True
+ if isIPAddress(expected_uri.hostname):
+ if clientip == expected_uri.hostname:
+ matched = True
else:
- # Now do hostname lookup
+ # Now do expected hostname -> IP lookup
try:
- host, aliases, _ignore_ips = socket.gethostbyaddr(clientip)
- for hostname in itertools.chain((host,), aliases):
- # Try host match
- if hostname == expected_uri.hostname:
+ # So now try the lookup of the expected host
+ _ignore_host, _ignore_aliases, ips = socket.gethostbyname_ex(expected_uri.hostname)
+ for ip in ips:
+ if ip == clientip:
matched = True
break
except socket.herror, e:
log.debug("iSchedule cannot lookup client ip '%s': %s" % (clientip, str(e),))
-
+
if not matched:
log.err("Originator not on allowed server: %s" % (self.originator,))
raise HTTPError(ErrorResponse(
Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py 2011-04-19 20:03:13 UTC (rev 7325)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py 2011-04-19 20:43:41 UTC (rev 7326)
@@ -14,8 +14,6 @@
# limitations under the License.
##
-from twext.python.filepath import CachingFilePath as FilePath
-
from twext.python.log import Logger
from twistedcaldav.client.pool import installPool
@@ -99,6 +97,7 @@
self.uri = None
self.thisServer = False
self.partitions = {}
+ self.isImplicit = True
def check(self):
# Check whether this matches the current server
@@ -135,6 +134,9 @@
ELEMENT_URI = "uri"
ELEMENT_PARTITIONS = "partitions"
ELEMENT_PARTITION = "partition"
+ATTR_IMPLICIT = "implicit"
+ATTR_VALUE_YES = "yes"
+ATTR_VALUE_NO = "no"
class ServersParser(object):
"""
@@ -157,6 +159,8 @@
log.error("Unknown server type: '%s' in servers file: '%s'" % (child.tag, xmlFile,), raiseException=RuntimeError)
server = Server()
+ server.isImplicit = child.get(ATTR_IMPLICIT, ATTR_VALUE_YES) == ATTR_VALUE_YES
+
for node in child.getchildren():
if node.tag == ELEMENT_ID:
server.id = node.text
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110419/6387e4ff/attachment-0001.html>
More information about the calendarserver-changes
mailing list