Exemple #1
0
	def create_propname(self):
	    """ create a multistatus response for the prop names """
	    dc=self.__dataclass
	    # create the document generator
	    doc = Document(None)
	    ms=doc.createElement("D:multistatus")
	    ms.setAttribute("xmlns:D","DAV:")
	    doc.appendChild(ms)

	    if self.__depth=="0":
		pnames=dc.get_propnames(self.__uri)
		re=self.mk_propname_response(self.__uri,pnames)
		ms.appendChild(re)

	    elif self.__depth=="1":
		pnames=dc.get_propnames(self.__uri)
		re=self.mk_propname_response(self.__uri,pnames)
		ms.appendChild(re)
		for newuri in dc.get_childs(self.__uri):
		    pnames=dc.get_propnames(newuri)
		    re=self.mk_propname_response(newuri,pnames)
		    ms.appendChild(re)
	    # *** depth=="infinity"	 

	    sfile=StringIO()
	    ext.PrettyPrint(doc,stream=sfile)
	    s=sfile.getvalue()
	    sfile.close()
	    return s
Exemple #2
0
    def create_propname(self):
        """ create a multistatus response for the prop names """
        dc = self.__dataclass
        # create the document generator
        doc = Document(None)
        ms = doc.createElement("D:multistatus")
        ms.setAttribute("xmlns:D", "DAV:")
        doc.appendChild(ms)

        if self.__depth == "0":
            pnames = dc.get_propnames(self.__uri)
            re = self.mk_propname_response(self.__uri, pnames)
            ms.appendChild(re)

        elif self.__depth == "1":
            pnames = dc.get_propnames(self.__uri)
            re = self.mk_propname_response(self.__uri, pnames)
            ms.appendChild(re)
            for newuri in dc.get_childs(self.__uri):
                pnames = dc.get_propnames(newuri)
                re = self.mk_propname_response(newuri, pnames)
                ms.appendChild(re)
        # *** depth=="infinity"

        sfile = StringIO()
        ext.PrettyPrint(doc, stream=sfile)
        s = sfile.getvalue()
        sfile.close()
        return s
Exemple #3
0
    def __init__(self):
        Document.__init__(self, None)
        # These only make sense in a browser environment, therefore
        # they never change
        self.__dict__['__referrer'] = ''
        self.__dict__['__domain'] = None
        self.__dict__['__URL'] = ''

        self.__dict__['__cookie'] = ''
        self.__dict__['__writable'] = 0
        self.__dict__['_html'] = vars(sys.modules['xml.dom.html'])
    def __init__(self):
        Document.__init__(self, None)
        # These only make sense in a browser environment, therefore
        # they never change
        self.__dict__["__referrer"] = ""
        self.__dict__["__domain"] = None
        self.__dict__["__URL"] = ""

        self.__dict__["__cookie"] = ""
        self.__dict__["__writable"] = 0
        self.__dict__["_html"] = vars(sys.modules["xml.dom.html"])
Exemple #5
0
    def __init__(self):
        Document.__init__(self, None)
        # These only make sense in a browser environment, therefore
        # they never change
        self.__dict__['__referrer'] = ''
        self.__dict__['__domain'] = None
        self.__dict__['__URL'] = ''

        self.__dict__['__cookie'] = ''
        self.__dict__['__writable'] = 0
        self.__dict__['_html'] = vars(sys.modules['xml.dom.html'])
    def tree_action(self):
        """ copy a tree of resources (a collection)

        Here we return a multistatus xml element.

        """
        dc = self.__dataclass
        base = self.__src

        ### some basic tests
        # test if dest exists and overwrite is false
        if dc.exists(self.__dst) and not self.__overwrite: raise DAV_Error, 412
        # test if src and dst are the same
        # (we assume that both uris are on the same server!)
        ps = urlparse.urlparse(self.__src)[2]
        pd = urlparse.urlparse(self.__dst)[2]
        if ps == pd: raise DAV_Error, 403

        result = dc.copytree(self.__src, self.__dst, self.__overwrite)
        #result=copytree(dc,self.__src,self.__dst,self.__overwrite)

        if not result: return None

        ###
        ### create the multistatus XML element
        ### (this is also the same as in delete.py.
        ###  we might make a common method out of it)
        ###

        doc = Document(None)
        ms = doc.createElement("D:multistatus")
        ms.setAttribute("xmlns:D", "DAV:")
        doc.appendChild(ms)

        for el, ec in result.items():
            re = doc.createElement("D:response")
            hr = doc.createElement("D:href")
            st = doc.createElement("D:status")
            huri = doc.createTextNode(quote_uri(el))
            t = doc.createTextNode(gen_estring(ec))
            st.appendChild(t)
            hr.appendChild(huri)
            re.appendChild(hr)
            re.appendChild(st)
            ms.appendChild(re)

        sfile = StringIO()
        ext.PrettyPrint(doc, stream=sfile)
        s = sfile.getvalue()
        sfile.close()
        return s
    def create_prop(self):
        """ handle a <prop> request

        This will

        1. set up the <multistatus>-Framework

        2. read the property values for each URI
           (which is dependant on the Depth header)
           This is done by the get_propvalues() method.

        3. For each URI call the append_result() method
           to append the actual <result>-Tag to the result
           document.

        We differ between "good" properties, which have been
        assigned a value by the interface class and "bad"
        properties, which resulted in an error, either 404
        (Not Found) or 403 (Forbidden).

        """


        # create the document generator
        doc = Document(None)
        ms=doc.createElement("D:multistatus")
        ms.setAttribute("xmlns:D","DAV:")
        doc.appendChild(ms)

        if self.__depth=="0":
            gp,bp=self.get_propvalues(self.__uri)
            res=self.mk_prop_response(self.__uri,gp,bp,doc)
            ms.appendChild(res)

        elif self.__depth=="1":
            gp,bp=self.get_propvalues(self.__uri)
            res=self.mk_prop_response(self.__uri,gp,bp,doc)
            ms.appendChild(res)


        for newuri in self.__dataclass.get_childs(self.__uri):
            gp,bp=self.get_propvalues(newuri)
            res=self.mk_prop_response(newuri,gp,bp,doc)
            ms.appendChild(res)

        sfile=StringIO()
        ext.PrettyPrint(doc,stream=sfile)
        s=sfile.getvalue()
        sfile.close()
        return s
    def create_prop(self):
        """ handle a <prop> request

        This will

        1. set up the <multistatus>-Framework

        2. read the property values for each URI
           (which is dependant on the Depth header)
           This is done by the get_propvalues() method.

        3. For each URI call the append_result() method
           to append the actual <result>-Tag to the result
           document.

        We differ between "good" properties, which have been
        assigned a value by the interface class and "bad"
        properties, which resulted in an error, either 404
        (Not Found) or 403 (Forbidden).

        """

        # create the document generator
        doc = Document(None)
        ms = doc.createElement("D:multistatus")
        ms.setAttribute("xmlns:D", "DAV:")
        doc.appendChild(ms)

        if self.__depth == "0":
            gp, bp = self.get_propvalues(self.__uri)
            res = self.mk_prop_response(self.__uri, gp, bp, doc)
            ms.appendChild(res)

        elif self.__depth == "1":
            gp, bp = self.get_propvalues(self.__uri)
            res = self.mk_prop_response(self.__uri, gp, bp, doc)
            ms.appendChild(res)

        for newuri in self.__dataclass.get_childs(self.__uri):
            gp, bp = self.get_propvalues(newuri)
            res = self.mk_prop_response(newuri, gp, bp, doc)
            ms.appendChild(res)

        sfile = StringIO()
        ext.PrettyPrint(doc, stream=sfile)
        s = sfile.getvalue()
        sfile.close()
        return s
    def tree_action(self):
        """ copy a tree of resources (a collection)

        Here we return a multistatus xml element.

        """
        dc=self.__dataclass
        base=self.__src

        ### some basic tests
        # test if dest exists and overwrite is false
        if dc.exists(self.__dst) and not self.__overwrite: raise DAV_Error, 412
        # test if src and dst are the same
        # (we assume that both uris are on the same server!)
        ps=urlparse.urlparse(self.__src)[2]
        pd=urlparse.urlparse(self.__dst)[2]
        if ps==pd: raise DAV_Error, 403
        
        
        result=dc.copytree(self.__src,self.__dst,self.__overwrite)
        #result=copytree(dc,self.__src,self.__dst,self.__overwrite)

        if not result: return None

        ###
        ### create the multistatus XML element
        ### (this is also the same as in delete.py.
        ###  we might make a common method out of it)
        ###

        doc = Document(None)
        ms=doc.createElement("D:multistatus")
        ms.setAttribute("xmlns:D","DAV:")
        doc.appendChild(ms)

        for el,ec in result.items():
                re=doc.createElement("D:response")
                hr=doc.createElement("D:href")
                st=doc.createElement("D:status")
                huri=doc.createTextNode(quote_uri(el))
                t=doc.createTextNode(gen_estring(ec))
                st.appendChild(t)
                hr.appendChild(huri)
                re.appendChild(hr)
                re.appendChild(st)
                ms.appendChild(re)
 
        sfile=StringIO()
        ext.PrettyPrint(doc,stream=sfile)
        s=sfile.getvalue()
        sfile.close()
        return s
Exemple #10
0
def make_xmlresponse(result):
    """ construct a response from a dict of uri:error_code elements """
    doc = Document.Document(None)
    ms = doc.createElement("D:multistatus")
    ms.setAttribute("xmlns:D", "DAV:")
    doc.appendChild(ms)

    for el, ec in result.items():
        re = doc.createElement("D:response")
        hr = doc.createElement("D:href")
        st = doc.createElement("D:status")
        huri = doc.createTextNode(quote_uri(el))
        t = doc.createTextNode(gen_estring(ec))
        st.appendChild(t)
        hr.appendChild(huri)
        re.appendChild(hr)
        re.appendChild(st)
        ms.appendChild(re)

    sfile = StringIO()
    ext.PrettyPrint(doc, stream=sfile)
    s = sfile.getvalue()
    sfile.close()
    return s
Exemple #11
0
 def createAttribute(self, name):
     return Document.createAttribute(self, string.upper(name))
Exemple #12
0
 def createAttribute(self, name):
     return Document.createAttribute(self, string.upper(name))