This HowTo? describes how to set up a folder so that new objects created by FTP or WebDAV are zwiki pages, not DTML documents. It's actually more of a discussion than a how-to at the moment.

From the ZopeList?:

 From: John Hunter <jdhunter@ace.bsd.uchicago.edu>
 Subject: Re: [Zope] PUT_factory to create ZWikiPage by default - help
 To: Zope Users <zope@zope.org>
 Date: 16 Apr 2001 17:26:16 -0500

 "John" == John Hunter <jdhunter@ace.bsd.uchicago.edu> writes:
 John> Following the advice of Dieter Maurer and Tres Seaver I am
 John> trying to use PUT_factory to override the default object
 John> type and create a ZWikiPage when I create a page by
 John> ange-ftp.  Because I am a zope and python newbie, I am
 John> having some trouble.

OK, I have finally got this thing working. Part of the problem was that I was trying to do this as a PythonScript instead of as an ExternalMethod. But from http://www.zope.org/Members/michel/Projects/Interfaces/NewObjectPutHandler regarding PUT_factory methods:

 MJ> PythonScripts cannot be used for this; you cannot give Python
 MJ> Scripts access to classes that have been protected by
 MJ> permissions. This includes any class that inherits from
 MJ> PropertyManager, for example.

I'll run though what I did step-by-step for the benefits of other newbies such as myself who want implement this:

1) Create a file in /the/path/to/zope/Extensions called PUT_ZwikiPage?.py (or name it whatever you like) with the content:

     def PUT_factory( self, name, typ, body ):
         """
            Override the default PUT method to make ZWikiPage the
            default type for ftp uploads
         """
         from Products.ZWiki.ZWikiPage import ZWikiPage

         if typ == 'text/plain':
              return ZWikiPage( '', __name__=name )
         return None

I think that returning None will invoke the default PUT handler from NullResources?.py

2) From the ZWiki folder you are working in, add an External Method with Select type to add->External Method

3) enter the following info in the fields in the dialog box:

     Id             PUT_factory                                                       
     Title          (optional)
     Module Name    PUT_ZwikiPage
     Function Name  PUT_factory

4) You're done. You should be able to create new links via ange-ftp.

Thanks to Dieter Maurer, Tres Seaver, Tim Hicks, and Brian Lloyd for useful info in previous responses and posts.

If you want the ZWikiPages? to be DTML enabled, you'll need a different PUT_factory external method:

 #/usr/local/Zope/Extensions/PUT_ZWikiPageDTML.py
 def PUT_factory( self, name, typ, body ):
        """
           Override the default PUT method to make a DTML enabled ZWikiPage the
           default type for ftp uploads
        """
        from Products.ZWiki.ZWikiPage import ZWikiPage
        if typ == 'text/plain':
               ob = ZWikiPage( '', __name__=name )
               ob.page_type = 'structuredtextdtml'
               return ob
        return None

--John Hunter


I found that using davfs for Linux, DTML documents were being created when I created or copied text files in a zwiki DAV directory, unless I added the following:
    if typ == 'text/x-unknown-content-type':
        return ZWikiPage( '', __name__=name )

--CraigAllen?


When i add an externalMethod in ZMI i get the following BadRequest? error.

The method PUT_factory is in the ZOPEHOME/Extensions folder. Permissions are 775. The id PUT_factory is not in use in the wanted folder in ZMI. Zope-2.6.0; ZWiki-0.11;

Adding ExternalMethod threw this error:

  Traceback (innermost last):
    * Module ZPublisher.Publish, line 150, in publish_module
    * Module ZPublisher.Publish, line 114, in publish
    * Module Zope, line 171, in zpublisher_exception_hook
    * Module ZPublisher.Publish, line 98, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 39, in call_object
    * Module Products.ExternalMethod.ExternalMethod, line 60, in manage_addExternalMethod
    * Module OFS.ObjectManager, line 244, in _setObject
    * Module OFS.ObjectManager, line 77, in checkValidId
  Bad Request

Error avoided by using another id (put) !

Renaming later to the wanted PUT_factory gives this error:

  Traceback (innermost last):
    * Module ZPublisher.Publish, line 150, in publish_module
    * Module ZPublisher.Publish, line 114, in publish
    * Module Zope, line 171, in zpublisher_exception_hook
    * Module ZPublisher.Publish, line 98, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 39, in call_object
    * Module OFS.CopySupport, line 221, in manage_renameObjects
    * Module OFS.CopySupport, line 232, in manage_renameObject
  Copy Error

--FlorianKonnertz,11-04

Solved: I had already a file property called PUT_factory! :-( - Deleted and method renaming was ok. --FloK,11-04,later


SimonMichael, 2002/11/06 21:13 GMT (via web):
I also got the Bad Request error when creating the external method. I was attempting to add it in the top-level folder of a CMF site.

CMF folders define their own PUT_factory method (in CMFCore/PortalFolder?.py) which is not overrideable (unlike portal_skins'). Instead, you are supposed to configure the CMF site's content_type_registry to select the appropriate CMF object type for a given filename or mime type.

I ran the CMF zwiki install script (in ZWiki/Extensions) and then in content_type_registry, changed "Document" to "Wiki Page". I don't know exactly how ftp communicates mime types to this thing but now when I create a file in efs (emacs' ange-ftp successor) it's a zwiki page.

So far so good, but the new page's page_type is not what I want and setting a standard_page_type folder property has no effect. Fix checked in to cvs.

Next, I see that the pages are always created empty. PortalFolder?'s PUT_factory seems to discard the body, which isn't very useful.

... --JohnDeBruyn, 2003/06/08 18:42 GMT
I have a zip file with several hundered pages from BridgesWiki which Ward Cunningham generously hosted using scripts that are fairly close to the original wiki. How do I up load these files to a wiki that I am running with Zope and Zwiki. I know how to do this one file at a time. What is the easiest way to up load files that are to be Zwiki pages. Thanks, JohnDeBruyn

bulk upload of zwiki pages --SimonMichael, 2003/06/09 09:39 GMT
One way would be to ftp them, after setting up things so PUT in your wiki folder creates zwiki pages by default. I'm not sure how to do this but there may be a zope how-to that helps. Using this method, you'd probably want to make sure your files have suitable wiki names first.

FTP and PUT combo --JohnDeBruyn, 2003/06/11 16:20 GMT
I will follow the leads here on FTP and PUT to transfer the Ward Wiki pages to Zwiki. Much appreciated and I will add what I learn to this page.


comments:

Plone ZWiki users - note SimonMichael's comment well! --berendes, Wed, 30 May 2007 13:52:20 -0700 reply
it's all the in content_type_registry for your site. This worked for me: go to the content_type_registry page, add a Predicate based on extension, use wiki as the extension (arbitrary), and then move it up in priority so it takes precedence over the default setting that turns text/* mimetypes into Page's.

The step-by-step solution worked well (even in 2010) --swiesebach, Mon, 28 Jun 2010 06:12:09 -0700 reply