[Zope] Extensionless Zope Objects in Dreamweaver MX
Nguyen Quan Son
sonnq@tinhvan.com
Tue, 1 Apr 2003 14:17:06 +0700
I have found a solution to this problem by patching webdav/davcmds.py and ZPublisher/BaseRequest.py. See diff files below.
How it works: Zope appends "appropriate" extensions to object's URL (according to meta_type and content_type) when it sends a
response to webdav client, and strips these extensions when it got a request from the client.
Nguyen Quan Son sonnq@tinhvan.com
Tinhvan Co. http://www.tinhvan.com
Hanoi, Vietnam
<CODE>
--- ORIGINAL
+++ ./lib/python/webdav/davcmds.py Tue Apr 01 10:28:24 2003
@@ -93,6 +93,47 @@
'<d:multistatus xmlns:d="DAV:">\n')
iscol=isDavCollection(obj)
if iscol and url[-1] != '/': url=url+'/'
+
+ # Append file extensions that Dreamweaver could recognize
+ meta_type = getattr(obj, 'meta_type', '')
+ try:
+ meta_type = str(meta_type).lower()
+ if meta_type == 'none': meta_type = ''
+ except:
+ meta_type = ''
+ content_type = getattr(obj, 'content_type', '')
+ if callable(content_type):
+ content_type = content_type()
+ try:
+ content_type = str(content_type).lower()
+ if content_type == 'none': content_type = ''
+ except:
+ content_type = ''
+ if meta_type.find('filesystem') < 0:
+ url_ext = os.path.splitext(url)[1].lower()
+ if content_type:
+ if content_type == 'text/html' and url_ext not in ['.html', '.htm']:
+ url += '.webdav.html'
+ elif content_type == 'text/xml' and url_ext not in ['.xml', '.dtd', '.xsd', '.xsl', '.xslt']:
+ url += '.webdav.xml'
+ elif content_type == 'text/css' and url_ext not in ['.css']:
+ url += '.webdav.css'
+ elif content_type == 'text/plain' and url_ext not in ['.txt']:
+ url += '.webdav.txt'
+ elif content_type == 'image/jpeg' and url_ext not in ['.jpg', '.jpeg']:
+ url += '.webdav.jpg'
+ elif content_type == 'image/gif' and url_ext not in ['.gif']:
+ url += '.webdav.gif'
+ elif content_type == 'image/png' and url_ext not in ['.png']:
+ url += '.webdav.png'
+ elif content_type == 'image/bmp' and url_ext not in ['.bmp']:
+ url += '.webdav.bmp'
+ else:
+ if meta_type in ['dtml method', 'dtml document'] and url_ext not in ['.html', '.htm', '.css', '.txt']:
+ url += '.webdav.html'
+ elif meta_type in ['script (python)'] and url_ext not in ['.py']:
+ url += '.webdav.py'
+
result.write('<d:response>\n<d:href>%s</d:href>\n' % safe_quote(url))
if hasattr(aq_base(obj), 'propertysheets'):
propsets=obj.propertysheets.values()
--- ORIGINAL
+++ ./lib/python/ZPublisher/BaseRequest.py Tue Apr 01 10:25:16 2003
@@ -15,6 +15,9 @@
from urllib import quote
import xmlrpc
+import re
+webdavExt = re.compile('[.]webdav[.]\w+', re.I)
+
UNSPECIFIED_ROLES=''
try:
@@ -173,6 +176,7 @@
The REQUEST must already have a PARENTS item with at least one
object in it. This is typically the root object.
"""
+ path = webdavExt.sub('', path)
request=self
request_get=request.get
if response is None: response=self.response
</CODE>
----- Original Message -----
From: <hpinson@indepthl.com>
To: <zope@zope.org>
Sent: Saturday, March 29, 2003 12:18 AM
Subject: [Zope] Extensionless Zope Objects in Dreamweaver MX
> Has anyone discovered a workaround / hack for editing extensionless
> Zope objects (ZPT, DTML-Methods, DTML-Documents) directly in
> Dreamweaver MX?
>
> Harlow Pinson
> Indepth Learning
> Email: hpinson@indepthl.com
> Web: http://www.indepthl.com
> Voice: 505-994-2135
> FAX: 208-475-7678
>
>
>