[CalendarServer-changes] [11463] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jul 5 10:44:43 PDT 2013
Revision: 11463
http://trac.calendarserver.org//changeset/11463
Author: cdaboo at apple.com
Date: 2013-07-05 10:44:43 -0700 (Fri, 05 Jul 2013)
Log Message:
-----------
Change URL aliases to allow ones with underscores to work. Also, support child aliases.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/util.py
CalendarServer/trunk/conf/caldavd-apple.plist
CalendarServer/trunk/conf/caldavd-test.plist
CalendarServer/trunk/conf/caldavd.plist
CalendarServer/trunk/twext/web2/resource.py
CalendarServer/trunk/twistedcaldav/stdconfig.py
Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py 2013-07-05 17:43:46 UTC (rev 11462)
+++ CalendarServer/trunk/calendarserver/tap/util.py 2013-07-05 17:44:43 UTC (rev 11463)
@@ -37,6 +37,7 @@
from twext.web2.auth.basic import BasicCredentialFactory
from twext.web2.dav import auth
from twext.web2.http_headers import Headers
+from twext.web2.resource import Resource
from twext.web2.static import File as FileResource
from twisted.application.service import Service
@@ -582,13 +583,26 @@
scheme=scheme, port=port, path=redirected_to)
)
- for name, info in config.Aliases.iteritems():
- if os.path.sep in name or not info.get("path", None):
- log.error("Invalid alias: {name}", name=name)
+ for alias in config.Aliases:
+ url = alias.get("url", None)
+ path = alias.get("path", None)
+ if not url or not path or url[0] != "/":
+ log.error("Invalid alias: URL: {url} Path: {path}", url=url, path=path)
continue
- log.info("Adding alias {name} -> {path}", name=name, path=info["path"])
- resource = FileResource(info["path"])
- root.putChild(name, resource)
+ urlbits = url[1:].split("/")
+ parent = root
+ for urlpiece in urlbits[:-1]:
+ child = parent.getChild(urlpiece)
+ if child is None:
+ child = Resource()
+ parent.putChild(urlpiece, child)
+ parent = child
+ if parent.getChild(urlbits[-1]) is not None:
+ log.error("Invalid alias: URL: {url} Path: {path} already exists", url=url, path=path)
+ continue
+ resource = FileResource(path)
+ parent.putChild(urlbits[-1], resource)
+ log.info("Added alias {url} -> {path}", url=url, path=path)
# Need timezone cache before setting up any timezone service
log.info("Setting up Timezone Cache")
Modified: CalendarServer/trunk/conf/caldavd-apple.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-apple.plist 2013-07-05 17:43:46 UTC (rev 11462)
+++ CalendarServer/trunk/conf/caldavd-apple.plist 2013-07-05 17:44:43 UTC (rev 11463)
@@ -140,15 +140,16 @@
<!-- Child aliases -->
<key>Aliases</key>
- <dict>
+ <array>
<!--
- <key>foo</key>
<dict>
+ <key>url</key>
+ <string>/foo</string>
<key>path</key>
<string>/path/to/foo</string>
</dict>
-->
- </dict>
+ </array>
<!--
Modified: CalendarServer/trunk/conf/caldavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test.plist 2013-07-05 17:43:46 UTC (rev 11462)
+++ CalendarServer/trunk/conf/caldavd-test.plist 2013-07-05 17:44:43 UTC (rev 11463)
@@ -124,15 +124,16 @@
<!-- Child aliases -->
<key>Aliases</key>
- <dict>
+ <array>
<!--
- <key>foo</key>
<dict>
+ <key>url</key>
+ <string>/foo</string>
<key>path</key>
<string>/path/to/foo</string>
</dict>
-->
- </dict>
+ </array>
<!--
Modified: CalendarServer/trunk/conf/caldavd.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd.plist 2013-07-05 17:43:46 UTC (rev 11462)
+++ CalendarServer/trunk/conf/caldavd.plist 2013-07-05 17:44:43 UTC (rev 11463)
@@ -106,15 +106,16 @@
<!-- Child aliases -->
<key>Aliases</key>
- <dict>
+ <array>
<!--
- <key>foo</key>
<dict>
+ <key>url</key>
+ <string>/foo</string>
<key>path</key>
<string>/path/to/foo</string>
</dict>
-->
- </dict>
+ </array>
<!--
Modified: CalendarServer/trunk/twext/web2/resource.py
===================================================================
--- CalendarServer/trunk/twext/web2/resource.py 2013-07-05 17:43:46 UTC (rev 11462)
+++ CalendarServer/trunk/twext/web2/resource.py 2013-07-05 17:44:43 UTC (rev 11463)
@@ -215,6 +215,19 @@
return self
return None
+ def getChild(self, path):
+ """
+ Get a static child - when registered using L{putChild}.
+
+ @param path: the name of the child to get
+ @type path: C{str}
+
+ @return: the child or C{None} if not present
+ @rtype: L{iweb.IResource}
+ """
+ return getattr(self, 'child_%s' % (path,), None)
+
+
def putChild(self, path, child):
"""
Register a static child.
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2013-07-05 17:43:46 UTC (rev 11462)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2013-07-05 17:44:43 UTC (rev 11463)
@@ -348,7 +348,8 @@
# browser authentication dialog should be used.
"WebCalendarAuthPath" : "",
- "Aliases": {},
+ # Define mappings of URLs to file system objects (directories or files)
+ "Aliases": [],
#
# Directory service
@@ -733,7 +734,7 @@
},
"Splitting": {
- "Enabled" : True,
+ "Enabled" : False, # False for now whilst we experiment with this
"Size" : 100 * 1024, # Consider splitting when greater than 100KB
"PastDays" : 14, # Number of days in the past where the split will occur
"Delay" : 60, # How many seconds to delay the split work item
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130705/53f82aaa/attachment-0001.html>
More information about the calendarserver-changes
mailing list