def test_namespaces(self): handler = XMLRPCHandler('api') ns = handler.namespace('ns') assert ns.prefix == 'ns' assert ns.handler is handler misc = ns.namespace('misc') assert misc.prefix == 'ns.misc' assert misc.handler is handler misc.register(hello) assert handler.funcs['ns.misc.hello'] is hello
session['logged_in'] = True flash('You were logged in') return redirect(url_for('show_entries')) return render_template('login.html', error=error) @app.route('/logout') def logout(): session.pop('logged_in', None) flash('You were logged out') return redirect(url_for('show_entries')) api = XMLRPCHandler('api') api.connect(app, '/api') flaskr = api.namespace('flaskr') @flaskr.register def new_post(username, password, title, text): if username != USERNAME or password != PASSWORD: raise Fault('bad_credentials', "The username and password are " "incorrect.") g.db.execute('insert into entries (title, text) values (?, ?)', [title, text]) g.db.commit() return True @flaskr.register def get_posts():