On Thu, 21 Apr 2011 12:33:09 -0700, RVince wrote:

> I am getting the following:
> 
> Error - <type 'exceptions.TypeError'>: cmseditorlinemethod() takes
> exactly 2 arguments (1 given)
> 
> When I make the following call:
> 
> http://localhost/eligibility/cmseditorlinemethod/474724434

That's not a call, that's a URL. It's also a link to localhost, which is 
*your* computer and not visible to us.

How about actually showing us the *actual call* you make? Cut and paste 
the line of code that calls cmseditorlinemethod, showing the arguments.

My *guess* is that you're calling it without providing any arguments:

instance.cmseditorlinemethod()

Python automatically injects the `self` argument, but it requires two: 
self and ssn:

> def cmseditorlinemethod(self, ssn):
[...]


An alternative explanation: you don't use `self` in the body of 
cmseditorlinemethod. Possibly cmseditorlinemethod is actually a stand-
alone function rather than a method, and you are calling it like this:

cmseditorlinemethod(ssn)

but you have mistakenly declared the function to take two arguments.

Really, the error message is quite explicit in your problem: you have one 
argument given, but two arguments are required. The only subtlety is that 
for method calls, the `self` argument is automatically provided rather 
than manually, but once you've learned that quirk of Python, what else do 
you need to know to solve this problem?

By the way, I know this is unsolicited advice, but I'm going to give it 
anyway. Look at your function:


def cmseditorlinemethod(self, ssn):
    c.details = Session.query(MSPResponse).filter(
                MSPResponse.beneficiaryssn == ssn).all()
    content = render('/cmseditorline.mako')
    return content


It looks to me like this function relies on no fewer than three global 
variables, two that you read from and one which you write to:

c
Session
MSPResponse

This is almost certainly poor design. Using global state is almost always 
harmful and should be avoided. 

(I don't include `render` in this, as using global functions is normally 
harmless.)

http://c2.com/cgi/wiki?GlobalVariablesAreBad



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to