Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing cherrypy in two modules but with only one cherrypy instance
    text
    copied!<p>I am using cherrypy for a project and use it in a main python script main.py In a method within the main app I import a module called authentication</p> <p><code>from authentication import auth</code> and then pass it the variable args. cherrypy has been used here already obviously</p> <pre><code>@cherrypy.expose def auth(self, *args): from authentication import auth auth = auth() page = common.header('Log in') authString = auth.login(*args) if authString: page += common.barMsg('Logged in succesfully', 1) page += authString else: page += common.barMsg('Authentication failed', 0) page += common.footer() return page </code></pre> <p>From within authentication.py I want to set session variables so I included cherrypy again</p> <pre><code>def login(self, *args): output = "&lt;b&gt;&amp;quot;args&amp;quot; has %d variables&lt;/b&gt;&lt;br/&gt;\n" % len(args) if cherrypy.request.body_params is None: output += """&lt;form action="/auth/login" method="post" name="login"&gt; &lt;input type="text" maxlength="255" name="username"/&gt; &lt;input type="password" maxlength="255" name="password"/&gt; &lt;input type="submit" value="Log In"&gt;&lt;/input&gt; &lt;/form&gt;""" output += common.barMsg('Not a member yet? Join me &lt;a href="/auth/join"&gt;here&lt;/a&gt;', 8) return output </code></pre> <p>The problem is the error <code>HTTPError: (400, 'Unexpected body parameters: username, password')</code> when I use this. I want to have the cherrypy instance from main.py accesible in authentication.py to set session variables here. How can I do that?</p> <p>I have also tried passing the cherrypy object like so <code>authString = auth.login(cherrypy, *args)</code> and omitted its inclusion in authentication.py however get the same error</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload