Commit bb3ef58c authored by 's avatar

Moved urlbase method to webdav.common, modified DAV propertysheet to exclude

host & port info in src properties.
parent ba6da303
......@@ -84,7 +84,7 @@
##############################################################################
"""Property sheets"""
__version__='$Revision: 1.36 $'[11:-2]
__version__='$Revision: 1.37 $'[11:-2]
import time, string, App.Management, Globals
from ZPublisher.Converters import type_converters
......@@ -92,6 +92,7 @@ from DocumentTemplate.DT_Util import html_quote
from Globals import HTMLFile, MessageDialog
from string import find,join,lower,split,rfind
from Acquisition import Implicit, Explicit
from webdav.common import urlbase
from ExtensionClass import Base
from Globals import Persistent
......@@ -620,9 +621,8 @@ class DAVProperties(Virtual, PropertySheet, View):
def dav__source(self):
vself=self.v_self()
if hasattr(vself, 'meta_type') and vself.meta_type in \
('Document', 'DTML Document', 'DTML Method'):
url=vself.absolute_url()
if hasattr(vself, 'document_src'):
url=urlbase(vself.absolute_url())
return '\n <n:link>\n' \
' <n:src>%s</n:src>\n' \
' <n:dst>%s/document_src</n:dst>\n' \
......
......@@ -85,10 +85,9 @@
"""Commonly used functions for WebDAV support modules."""
__version__='$Revision: 1.3 $'[11:-2]
import string, time
__version__='$Revision: 1.4 $'[11:-2]
import string, time, urllib
......@@ -129,4 +128,10 @@ def rfc1123_date(ts=None):
return '%s, %s %s %s %s GMT' % (ts[0],ts[2],ts[1],ts[4],ts[3])
def urlbase(url, ftype=urllib.splittype, fhost=urllib.splithost):
# Return a '/' based url such as '/foo/bar', removing
# type, host and port information if necessary.
if url[0]=='/': return url
type, uri=ftype(url)
host, uri=fhost(uri)
return uri
......@@ -85,10 +85,10 @@
"""WebDAV xml request objects."""
__version__='$Revision: 1.4 $'[11:-2]
__version__='$Revision: 1.5 $'[11:-2]
import sys, os, string, regex
from common import absattr, aq_base, urlfix
from common import absattr, aq_base, urlfix, urlbase
from OFS.PropertySheets import DAVProperties
from xmltools import XmlParser
from cStringIO import StringIO
......@@ -150,7 +150,7 @@ class PropFind:
result=StringIO()
depth=self.depth
url=urlfix(self.request['URL'], 'PROPFIND')
url=rel_url(url)
url=urlbase(url)
result.write('<?xml version="1.0" encoding="utf-8"?>\n' \
'<d:multistatus xmlns:d="DAV:">\n')
iscol=hasattr(obj, '__dav_collection__')
......@@ -220,7 +220,7 @@ class PropFind:
result=StringIO()
depth=self.depth
url=urlfix(self.request['URL'], 'PROPFIND')
url=rel_url(url)
url=urlbase(url)
result.write('<?xml version="1.0" encoding="utf-8"?>\n' \
'<d:multistatus xmlns:d="DAV:">\n')
iscol=hasattr(obj, '__dav_collection__')
......@@ -414,9 +414,4 @@ class Lock:
def rel_url(url, r=regex.compile('http://\([^:/]+\)\(:[0-9]+\)?\(/.+\)?',
regex.casefold)):
if r.match(url) >= 0:
host,port,uri=r.group(1,2,3)
return uri or '/'
else: raise ValueError, url
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment