PloneFormGen passing data to an external method

1 message Options
Embed this post
Permalink
John_H2O

PloneFormGen passing data to an external method

Reply Threaded More More options
Print post
Permalink
Hello, I'm trying to pass the request.form data to an external method to be written to the file system, or emailed, or ... Below is the general outline of what I'm trying to do. I get an error: type 'dict' is not callable. Any ideas!?!? Please help.  hilsen.

I have the form (PFG form), Script (myPythonScript), and an external method (EM):

in the PFG form I have the After Validation Script set to "here/myPythonScript"

in myPythonScript I have:

# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE =  request.RESPONSE

#call external method to get existing data
ENTRIES = context.getdata(context, request)

in EM I have (modified...):

def getdata(self, request, keys=''):
        '''
        possible ways to call this function:
        value=getdata('key')
        dict=getdata(('key1','key2')) #get subset
        dict=getdata() #return everything
        It assumes you don't have the same key for
        GET and POST methods
        '''
        import types

        key_type=type(keys)
        d_data={} #initialize dictionary
        if keys=='': #if they don't supply keys then return everything
                for key in request.form:
                        d_data[key]=request.form(key)
                for key in request.querystring:
                        d_data[key]=request.querystring(key)
                return d_data
        elif key_type == types.StringType: #if they provide a single string
                value=request.form(keys)
                if (value != 'None') and (str(value) == 'None'):
                        return request.querystring(keys)
                else:
                        return value
        #if they provide a list then return a dictionary with all the key/values
        elif key_type == types.TupleType or key_type == types.ListType:
                for key in keys:
                        value=request.form(key)
                        #now check if the data was empty, if so look at QueryString
                        if (value != 'None') and (str(value) == 'None'):
                                value=request.querystring(key)
                        data[key]=value
                return d_data


_______________________________________________
Plone-Scandinavia mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/plone-scandinavia