1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Common/Configurator/Resources/config_dav.xsl Tue Jan 25 17:00:47 2005 +0000
1.3 @@ -0,0 +1,81 @@
1.4 +<?xml version="1.0" encoding="utf-8"?>
1.5 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.6 + xmlns:D="DAV:"
1.7 + version="1.0">
1.8 +
1.9 + <xsl:param name="path"/>
1.10 + <xsl:param name="start"/>
1.11 +
1.12 + <xsl:template match="database">
1.13 + <D:multistatus>
1.14 + <xsl:choose>
1.15 + <!-- Specified part of the database. -->
1.16 + <xsl:when test="$start != ''">
1.17 + <!-- Emit the container. -->
1.18 + <xsl:call-template name="resource">
1.19 + <xsl:with-param name="element" select="//*[local-name() = $start][1]"/>
1.20 + <xsl:with-param name="container">true</xsl:with-param>
1.21 + </xsl:call-template>
1.22 + <!-- Emit all resources. -->
1.23 + <xsl:for-each select="//*[local-name() = $start]/*">
1.24 + <xsl:call-template name="resource">
1.25 + <xsl:with-param name="element" select="."/>
1.26 + </xsl:call-template>
1.27 + </xsl:for-each>
1.28 + </xsl:when>
1.29 + <!-- Top level. -->
1.30 + <xsl:otherwise>
1.31 + <!-- Emit the container. -->
1.32 + <xsl:call-template name="resource">
1.33 + <xsl:with-param name="element" select="."/>
1.34 + <xsl:with-param name="container">true</xsl:with-param>
1.35 + </xsl:call-template>
1.36 + <!-- Emit all resources. -->
1.37 + <xsl:for-each select="*">
1.38 + <xsl:call-template name="resource">
1.39 + <xsl:with-param name="element" select="."/>
1.40 + </xsl:call-template>
1.41 + </xsl:for-each>
1.42 + </xsl:otherwise>
1.43 + </xsl:choose>
1.44 + </D:multistatus>
1.45 + </xsl:template>
1.46 +
1.47 + <xsl:template name="resource">
1.48 + <xsl:param name="element"/>
1.49 + <xsl:param name="container"/>
1.50 + <D:response>
1.51 + <xsl:choose>
1.52 + <xsl:when test="$container != ''">
1.53 + <D:href><xsl:value-of select="$path"/>/</D:href>
1.54 + </xsl:when>
1.55 + <xsl:otherwise>
1.56 + <D:href><xsl:value-of select="$path"/>/<xsl:value-of select="local-name()"/><xsl:if test="count($element/*) != 0">/</xsl:if></D:href>
1.57 + </xsl:otherwise>
1.58 + </xsl:choose>
1.59 + <D:propstat>
1.60 + <D:prop>
1.61 + <D:creationdate>2004-10-13T23:57:00Z</D:creationdate>
1.62 + <xsl:choose>
1.63 + <xsl:when test="$container != ''">
1.64 + <D:displayname><xsl:value-of select="$path"/></D:displayname>
1.65 + </xsl:when>
1.66 + <xsl:otherwise>
1.67 + <D:displayname><xsl:value-of select="local-name()"/></D:displayname>
1.68 + </xsl:otherwise>
1.69 + </xsl:choose>
1.70 + <D:resourcetype>
1.71 + <xsl:if test="count($element/*) != 0">
1.72 + <D:collection/>
1.73 + </xsl:if>
1.74 + </D:resourcetype>
1.75 + <xsl:if test="count($element/*) = 0">
1.76 + <D:getcontenttype>text/html</D:getcontenttype>
1.77 + </xsl:if>
1.78 + </D:prop>
1.79 + <D:status>HTTP/1.1 200 OK</D:status>
1.80 + </D:propstat>
1.81 + </D:response>
1.82 + </xsl:template>
1.83 +
1.84 +</xsl:stylesheet>
2.1 --- a/examples/Common/Configurator/__init__.py Tue Jan 25 17:00:34 2005 +0000
2.2 +++ b/examples/Common/Configurator/__init__.py Tue Jan 25 17:00:47 2005 +0000
2.3 @@ -64,6 +64,28 @@
2.4 fields = XSLForms.Fields.Fields(encoding=self.encoding, values_are_lists=1)
2.5 parameters = trans.get_fields_from_body(self.encoding)
2.6 documents = fields.make_documents(parameters.items())
2.7 + elif method == "PROPFIND":
2.8 + dav_xsl = os.path.join(self.resource_dir, "config_dav.xsl")
2.9 + database_xml = os.path.join(self.resource_dir, "config_database.xml")
2.10 + database = libxml2dom.parse(database_xml)
2.11 +
2.12 + # Process the path.
2.13 +
2.14 + parts = trans.get_path_info().split("/")
2.15 + if not parts[-1]:
2.16 + del parts[-1]
2.17 +
2.18 + start = parts[-1]
2.19 + path = "/".join(parts)
2.20 + proc = XSLOutput.Processor([dav_xsl], parameters={
2.21 + "path" : path,
2.22 + "start" : start
2.23 + })
2.24 +
2.25 + trans.set_response_code(207)
2.26 + proc.send_output(trans.get_response_stream(), trans.get_response_stream_encoding(),
2.27 + database)
2.28 + raise WebStack.Generic.EndOfResponse
2.29 else:
2.30 trans.set_response_code(405)
2.31 raise WebStack.Generic.EndOfResponse
2.32 @@ -101,7 +123,7 @@
2.33
2.34 database_xsl = os.path.join(self.resource_dir, "config_database.xsl")
2.35 database_xml = os.path.join(self.resource_dir, "config_database.xml")
2.36 - proc = XSLOutput.Processor([database_xsl], {"database" : database_xml})
2.37 + proc = XSLOutput.Processor([database_xsl], references={"database" : database_xml})
2.38 configuration = proc.get_result(configuration)
2.39
2.40 # Start the response.