[Zope] Windows webdav clients (Teamdrive, Webdrive), zope and dreamweaver

Heimo Laukkanen huima@fountainpark.org
Tue, 24 Dec 2002 03:50:29 +0200


This is a multi-part message in MIME format.
--------------080303020606060206050207
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi all,

I did some dancing over webdav with windows and found totally new 
problems and solved them too. I downloaded both latest teamdrive and 
webdrive to my windows laptop, and used them to access Zope ( 2.6.0 ) 
through webdav.

In Zope I had created a PUT_factory, which maps files saved ending with 
.html, .htm, .HTML and .HTM to Zope Page template. As I was using 
teamdrive / xythos client with Dreamweaver ( 4.01 ) I noticed that if I 
opened a pagetemplate ( something.html ) through webdav and saved it 
again, the template got saved as a File - rather than a pagetemplate, as 
it was supposed. When I tried the same with other text-application, like 
textpad , similar did not happen - also it did not happen if I used 
Webdrive as a webdav client or Dreamweaver's own internal webdav-client.

Looking at webdavlogger's log and access logs I noticed that there was 
something different how teamdrive and webdrive were implemented. Also we 
have to remember that Dreamweaver makes a strange temp-file dance, when 
saving a file.

With Teamdrive Dreamweaver's tmp file was apparently moved / renamed to 
.html, while webdrive managed the same differently. So in the sense of 
how everything happened in Zope with teamdrive was:

Create a temp file Something.tmp and do put
Delete old real-file.html
Rename / Move Something.tmp to real-file.html

While this happened, the object that was created was a file - and not a 
pagetemplate.

As soon as a realised this, it was easy to fix the PUT_factory to map 
also .tmp files to pagetemplate. Included is a PUT_factory for an example.

Hope this helps others too.

Reference:
http://www.zope.org/Members/glpb/dwhowto

-huima

--------------080303020606060206050207
Content-Type: text/plain;
 name="vaisala_put.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="vaisala_put.py"

from Products.PythonScripts.PythonScript import PythonScript

from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate

from OFS.DTMLDocument import DTMLDocument

from OFS.Image import Image

from OFS.Image import File


def PUT_factory( self, name, typ, body ):

    # Gimme a PageTemplate or a PythonScript, but never DTML!

    if typ=='text/x-python' or (body and body[0]=='#'):

        ob = PythonScript( name )

    elif typ.startswith('text'):

        ob = ZopePageTemplate(name, body, content_type='text/html')        

    elif typ.startswith('image/'):

        ob = Image(name, '', body, content_type=typ)

    elif name.endswith('html'):

        ob = ZopePageTemplate(name, body, content_type='text/html')

    elif name.endswith('htm'):

        ob = ZopePageTemplate(name, body, content_type='text/html')

    elif name.endswith('HTML'):

        ob = ZopePageTemplate(name, body, content_type='text/html')

    elif name.endswith('HTM'):

        ob = ZopePageTemplate(name, body, content_type='text/html')

    elif name.endswith('tmp'):

        ob = ZopePageTemplate(name, body, content_type='text/html')

    elif name.endswith('TMP'):

        ob = ZopePageTemplate(name, body, content_type='text/html')

    else:

        ob = File(name, '', body, content_type=typ)

    return ob



--------------080303020606060206050207--