Personal tools
You are here: Home Documentation How-tos Edit Skins Over Webdav
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Edit Skins Over Webdav

This How-to applies to: Any version.
This How-to is intended for: Integrators, Customizers

Some webdav clients (Mac OS X) create new files on every write, losing the object type information. This script gets webdav editing to work for page templates, css files and images in portal_skins.

Tested With

  • Zope 2.7.3
  • Mac OS X 10.3.5 (as the webdav client)

What to do

The following script has been hacked together from many sources found googling for PUT_factory. Name it put_factory.py and put it in the Extensions folder of your Zope instance, then add an external method to portal_skins with id PUT_factory module put_factory :

  from Products.PythonScripts.PythonScript import PythonScript
  from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
  from OFS.DTMLMethod import DTMLMethod
  from OFS.Image import Image
  from OFS.Image import File

  def PUT_factory(self, name, typ, body):
    ''' Try to guess the right object type
    '''
    if typ=='text/x-python' or (body and body[0]=='#'):
        ob = PythonScript(name)
    elif name.endswith('.css'):
        ob = DTMLMethod(name, body)
    elif typ.startswith('text'):
        ob = ZopePageTemplate(name, body, content_type='text/html')
    elif typ.startswith('image')
        ob = Image(name, '', body, content_type=typ)
    else:
        ob = File(name, '', body, content_type=typ)

    return ob

Note

You will still lose usable undo history for the objects as on a file save OS X renames the old file, uploads the file as new and finally deletes the renamed old file.

Contributed by Laurence Rowe

by Laurence Rowe last modified February 4, 2006 - 17:23 All content is copyright Plone Foundation and the individual contributors.

Problems

Posted by Sam Richards at July 9, 2006 - 19:15

There was a missing ":" from the above script.

I also had problems adding the external method under portal_skins, but it worked under the zope root node.

I was having the problem that while I could write files there, when I reloaded them, I seemed to get an attribute file. This appeared to solve that problem.

Another link

Posted by Sam Richards at July 9, 2006 - 19:16

I was going to add that this link http://myzope.kedai.com.my/blogs/kedai/37 helped me quite a bit.


For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by