[Zope] Programmatic creation/update of ZSQL methods

Charlie Reiman creiman@kefta.com
Fri, 1 Nov 2002 13:44:35 -0800


Got PUT_factory working. For those interested, here's my current
PUT_factory. I also found a typo in my xml test but fixing it didn't help. I
still can't create ZSQLMethods via xmlrpc. But now it doesn't bother me so
much.

#   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