[Zope] differentiate dtml method from document
Thu, 31 May 2001 08:23:21 -0400
> Is there a suffix I can add to DTML Methods that would then be
> recognized by the ZODB upon creating an object externally like from
> within Dreamweaver?
> If I create an object externally and call it SOMEFILE.DTML
> - it is recognized as a DTML Document.
> Ok, good. But, now I want to create a file that will be recognized
> as a DTML METHOD.
Zope doesn't care primarily about the suffix; its PUT handling (for
WebDAV/FTP/HTTP PUTs) looks at the Content-Type header (if there is
one; no such luch with FTP), and only reverts to guessing type from
extension if it is not there.
You can override the default behavior using the 'PUT_factory' hook,
Essentially, you would drop in an ExternalMethod which did the name
recognition you desired, e.g.::
# Implement the "hookable PUT" hook.
import re, OFS.DTMLMethod
NAME_PATTERN = re.compile( '^.*\.dtml$' )
def PUT_factory( self, name, typ, body ):
if NAME_PATTERN.match( name ):
return OFS.DTMLMethod.DTMLMethod( '', __name__=name )
Tres Seaver email@example.com
Digital Creations "Zope Dealers" http://www.zope.org