Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1416 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

TypeError on do_decorate

Reported by: mikl Owned by: anonymous
Priority: normal Milestone: 1.0.3
Component: TurboGears Version: 1.0.2
Severity: normal Keywords:
Cc:

Description

I have a controller looking like this

class SignUpController(controllers.Controller):
    @expose(template="turbomailmaster.template.signup_index")
    def index(self):
        return dict()

    @expose
    def submit(self, email, action, submit):
        if Recipient.get_by(email_address=email):
            turbogears.flash("%s is already added to the list" % email)
            raise turbogears.redirect('/signup/confirm')
        
        if True: #Validate e-mail-address here
            recipient = Recipient(email)
            turbogears.flash("%s has been added to the list" % email)
            raise turbogears.redirect('/signup/confirm')
        else:
            raise turbogears.redirect('/signup/email_error')

    @expose(template="turbomailmaster.template.signup_confirm")
    def confirm(self):
        return dict()
    
    @expose(template="turbomailmaster.template.signup_email_error")
    def email_error(self):
        return dict()

class Root(controllers.RootController):
    signup = SignUpController

[snip]

This is fairly standard, but when I try to run any of the /signup/ methods, I get this (this is from  http://localhost:8080/signup/submit):

Page handler: <unbound method SignUpController.do_decorate>
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/cherrypy/_cphttptools.py", line 105, in _run
    self.main()
  File "/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/cherrypy/_cphttptools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
TypeError: unbound method do_decorate() must be called with SignUpController instance as first argument (got nothing instead)

Change History

comment:1 follow-up: ↓ 2 Changed 12 years ago by faide

What happend if you put @expose() instead of @expose on your submit method ?

comment:2 in reply to: ↑ 1 Changed 12 years ago by mikl

Replying to faide:

What happend if you put @expose() instead of @expose on your submit method ?

That makes no difference...

I also get the same error on the other methods...

TypeError: unbound method confirm() must be called with SignUpController instance as first argument (got nothing instead)

comment:3 follow-up: ↓ 4 Changed 12 years ago by faide

  • Status changed from new to closed
  • Resolution set to fixed

Argh ! Sorry I did not spot this earlier :):)

you should replace:

signup = SignUpController?

by

signup = SignUpController?()

and now your methods will be bound to an instance :p

comment:4 in reply to: ↑ 3 Changed 12 years ago by faide

You should have read :

signup = SignUpController()

I always forget to use code blocks when type code in there :-/

comment:5 Changed 12 years ago by mikl

Bleh, I should have seen that long ago - thanks for your help... :)

Note: See TracTickets for help on using tickets.