Search code examples
pythonsessionweb.py

web.py rendering wrong page, path not correct


I'm working with web.py on a project with a user authentication component. This project has a /demo directory and a /register directory.

The problem is that for some reason, clicking the button meant to travel to the /register directory goes to /demo instead. Interestingly, if I type /register at the end of the URL, /register appears properly. The URL is different in this case, lacking the ?register=Register part that comes from clicking the button.

The specific error that appears when I click on the register button is this:

type 'exceptions.TypeError'> at /demo __template__() takes exactly 1 argument (0 given)

The code that it points to as a problem area is this:

class demo:
   def GET(self):
      render = create_render(session.get('privilege', 0))
      return '%s' % render.demo() # Specifically this line generates the error.

I don't think there is any weird fall through, as in the code there are two classes implemented between the register class and the demo class. They're actually implemented in the order they're displayed in the urls list, with reset and profile in between the two.

I don't think there is anything wrong with my urls list:

urls = (
  '/', 'index',
  '/register', 'register',
  '/reset', 'reset',
  '/profile', 'profile',
  '/demo', 'demo',
  '/entropy', 'entropy',
)

Here also is the HTML code for the buttons:

<form action="demo" method="GET">
   <input type="submit" name="demo" value="Demo"/>
<form/>

<form action="register" method="GET">
    <input type="submit" name="register" value="Register"/>
</form>

Other potentially relevant bits of code:

register.GET():

class register:   
    def GET(self):
        reg_form = forms.registration_form()
        render = create_render(session.get('privilege'))
        return render.register()

create_privilege(privilege): (Explained here, at #4)

def create_render(privilege):
    if logged():
        render = web.template.render('templates/logged', base='base')
    else:
        render = web.template.render('templates/', base="base")
    return render

So, I suppose, the final question is this: Why is the button rendering the wrong page? I can post more code if need be!

Thank you!


Solution

  • I fixed it! There was an issue in one of the HTML buttons, a form tag was not closed properly. What a silly error.