[Zope] Setting meta types for FTP's objects

Charlie Reiman creiman@kefta.com
Fri, 22 Nov 2002 13:54:13 -0800


Mostly, you don't.

But you can set up a PUT_factory method. Search the archives or zope.org for
PUT_factory or hookable_PUT. I'm attaching my below which defaults to DTML
Methods unless it sees '<params>', in which case it creates a ZSQL Method
with my defaults. You'll still need to search the archives to know how to
install it.

#   Implement the "hookable PUT" hook.
import re, OFS.DTMLMethod
import Products.ZSQLMethods.SQL

import sys

TEXT_PATTERN = re.compile( r'^text/.*$' )
ZSQL_PATTERN = re.compile( r'<params>([^<]+)</params>(.*)', re.DOTALL )

# New behaviors:
# Support for ftp put of ZSQL methods (sorta). Connection ID is hardcoded.
# Default doctype is DTMLMethod, not DTMLDocument.

def PUT_factory( self, name, typ, body ):
  """
  """
  if TEXT_PATTERN.match( typ ):
    grps = ZSQL_PATTERN.match(body)
    if grps:
      return Products.ZSQLMethods.SQL.SQL(name, '',
               'Oracle_database_connection', grps.group(1),
               grps.group(2))
    else:
      return OFS.DTMLMethod.DTMLMethod( '', __name__=name )
  return None




> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Dennis Allison
> Sent: Friday, November 22, 2002 1:27 PM
> To: zope@zope.org
> Subject: [Zope] Setting meta types for FTP's objects
>
>
> How does one get the metatypes set properly for objects imported using
> FTP?   How do I inform Zope that a file is a SQL-method, dtml-method,
> dtml-document, or whatever?  A quick google of the archives did not turn
> up anything...
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>