[Zope-CMF] "editor can't find a valid editor for this file extension" when a ttempting to use webdav and Dreamweaver

Nguyen Quan Son sonnq@tinhvan.com
Thu, 3 Apr 2003 10:24:34 +0700


Hi all,
We are using DW MX for editing Page Template, DTML, Python Script and other document types.
Here is how we setup DW and Zope to work together:

1. Patch WEBDAV (see diff file below, in the <CODE> section) so 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 off when it got a request from the client.

2. Add "Python" document type so DW opens Python scripts in code editor:

- Modify "Configuration\DocumentTypes\MMDocumentTypes.xml":
<?xml version="1.0"?>
<documenttypes ...>
......
<documenttype id="Python" internaltype="Text" winfileextension="py" macfileextension="py" file="Default.txt">
  <TITLE>Python</TITLE>
  <description>Python script</description>
</documenttype>
</documenttypes>

- Modify "Configuration\Extensions.txt":
HTM,HTML,SHTM,.......,PY:All Documents
PY:Python

- Add ".py" extension to "Open in Code View" in menu Edit -> Preferences -> File Type / Editors

3. DW MX sometimes strips off the ending slash in <metal> and <tal> tags, as in the following code:
  <metal:block fill-slot="css_slot">
    <metal:block define-slot="css_slot" />        # -> DW will remove this ending slash
  </metal:block>
You can fix that by adding new tags "metal:block", "tal:block"... to Tag Library

Regards,
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: "Sally Owens" <sowens@brookes.ac.uk>
To: "Slade Mrs A" <A.Slade@rmcs.cranfield.ac.uk>; "Zope-CMF Mailing List (E-mail)" <zope-cmf@zope.org>
Sent: Wednesday, April 02, 2003 9:22 PM
Subject: Re: [Zope-CMF] "editor can't find a valid editor for this file extension" when a ttempting to use webdav and Dreamweaver


> We have not been able to get this to work either. DW needs a file to end in 
> .html in order to know that it can open it. Because your page templates 
> wont have extensions of .pt the changes you describe below wont have an 
> effect. The advice we got was to give all our CMF content/template 
> instances names that end in .html. We're not keen to do this because it 
> isn't the way that Zope/CMF were designed to work.
> 
> We're looking at alternatives - possibly editing FTP_GET so that it appends 
> .html to every filename and FTP_PUT so that it strips it off again - just 
> so that DW thinks it's a HTML file. Not sure yet whether this will work.
> 
> Sally
> 
> PS you can 'force' DW to open the file by browsing to the local copy of the 
> (template) file using windows explorer, right-clicking and selecting 'Open 
> With' (browse to DW).
> 
> At 18:28 27/03/03 +0000, Slade Mrs A wrote:
> >Hi,
> >
> >It seems everyone else who has posted has made it further than I have with
> >Dreamweaver working nicely with CMF.  I get CMF talking to Dreamweaver, but
> >when I try to edit any of the page templates (i.e., header), I get the
> >following error with both Dreamweaver 4.01 and MX:
> >
> >"editor can't find a valid editor for this file extension"
> >
> >I have made the appropriate changes to Configuration/Extentions.txt:
> >PT,HTM,HTML, ..... :All Documents
> >PT:Zope Presentation Templates
> >HTM,HTML:HTML Documents
> >
> >Can anyone provide me with some next steps?
> >
> >Thanks,
> >April
> >
> >April Slade
> >Web Developer
> >Information Services
> >Cranfield University (RMCS)
> >Shrivenham
> >SWINDON
> >SN6 8LA
> >
> >Tel: +44 (0)1793 785361
> >Fax: +44 (0)1793 785555
> >a.slade@rmcs.cranfield.ac.uk
> >
> >
> >_______________________________________________
> >Zope-CMF maillist  -  Zope-CMF@zope.org
> >http://mail.zope.org/mailman/listinfo/zope-cmf
> >
> >See http://collector.zope.org/CMF for bug reports and feature requests
> 
> 
>