Craig
Craig

Reputation: 3

Plone External methods help

I'm having trouble getting a simple external methods in plone working correctly. In my extensions folder I have a python script named blast_query.py code below:

def print_query(self, x):
    print(x)

my external methods looks like:

Id: run_blast_query

Title:

Module Name: blast_query

Function Name: print_query

My python script in the ZMI looks like:

#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

# Insert data that was passed from the form
query=request.query

context.print_query(context,query)

I just want to pass the query from the form to the function so i know i have it working correctly.

Any ideas?

Upvotes: 0

Views: 1282

Answers (3)

sureshvv
sureshvv

Reputation: 4422

"request" is available from "self".

use self.REQUEST inside your external method.

No extra parameter needed.

Upvotes: 0

Auspex
Auspex

Reputation: 2254

This is a problem with your understanding of python methods.

I would expect:

context.print_query(context,query)

to return:

TypeError: print_query() takes exactly 2 arguments (3 given)

Remember, in python, obj.method() implicitly passes obj as the first parameter of method()

Upvotes: 0

Alex M
Alex M

Reputation: 51

You should call your external method by id:

context.run_blast_query(context,query)

Upvotes: 1

Related Questions