def app(self): return web.method('POST') | web.cases( Rule('/_update_lock/<string:item_id>/<string:edit_session>', self.update_lock), Rule('/_force_lock/<string:item_id>', self.force_lock), Rule('/_release_lock/<string:item_id>/<string:edit_session>', self.release_lock))
def app(self): prepare = self.PrepareItemHandler(self) return web.cases( web.match('', '') | prepare | self, web.match('/autosave', 'autosave') | \ web.method('POST', strict=True) | prepare | self.autosave )
def test_simple_match(self): """Method""" from webob.exc import HTTPMethodNotAllowed app = web.cases( web.match("/", "simple") | web.method("post"), web.match("/second", "second") | web.method("POST"), web.match("/strict", "strict") | web.method("post", strict=True), ) | (lambda e, d: Response()) self.assertEqual(web.ask(app, "/"), None) self.assertEqual(web.ask(app, "/", method="post").status_int, 200) self.assertEqual(web.ask(app, "/second", method="post").status_int, 200) self.assertRaises(HTTPMethodNotAllowed, lambda: web.ask(app, "/strict").status_int) self.assertEqual(web.ask(app, "/strict", method="post").status_int, 200)
def test_simple_match(self): '''Method''' from webob.exc import HTTPMethodNotAllowed app = web.cases( web.match('/', 'simple') | web.method('post'), web.match('/second', 'second') | web.method('POST'), web.match('/strict', 'strict') | web.method('post', strict=True) ) | (lambda e,d: Response()) self.assertEqual(web.ask(app, '/'), None) self.assertEqual(web.ask(app, '/', method='post').status_int, 200) self.assertEqual(web.ask(app, '/second', method='post').status_int, 200) self.assertRaises(HTTPMethodNotAllowed, lambda: web.ask(app, '/strict').status_int) self.assertEqual(web.ask(app, '/strict', method='post').status_int, 200)
def app(self): # Be careful, put prepare handler only after match! Otherwise it brakes # file upload (yes, its not obvious!) prepare = self.PrepareItemHandler(self) return self.app_prefix | web.cases( web.match("", "") | prepare | self, web.match("/autosave", "autosave") | web.method("POST", strict=True) | prepare | self.autosave, )
def app(self): return web.prefix('/tray') | web.cases( Rule('/<int:tray>', self.tray), web.prefix('/_') | web.method('POST', strict=True) | web.cases( Rule('/put', self.put_to_tray), Rule('/user/put', self.put_to_user_tray), Rule('/delete', self.delete_from_tray), ) )
def app(self): # Be careful, put prepare handler only after match! Otherwise it brakes # file upload (yes, its not obvious!) prepare = self.PrepareItemHandler(self) return self.app_prefix | web.cases( web.match('', '') | prepare | self, web.match('/autosave', 'autosave') | \ web.method('POST', strict=True) | prepare | self.autosave )
def app(self): # Be careful, put prepare handler only after match! Otherwise it brakes # file upload (yes, its not obvious!) prepare = self.PrepareItemHandler(self) return self.app_prefix | web.cases( web.match('', '') | prepare | self, web.match('/autosave', 'autosave') | \ web.method('POST', strict=True) | prepare |self.autosave )
def test_simple_match(self): '''Method''' from webob.exc import HTTPMethodNotAllowed app = web.cases( web.match('/', 'simple') | web.method('post'), web.match('/second', 'second') | web.method('POST'), web.match('/strict', 'strict') | web.method('post', strict=True)) | (lambda e, d: Response()) self.assertEqual(web.ask(app, '/'), None) self.assertEqual(web.ask(app, '/', method='post').status_int, 200) self.assertEqual( web.ask(app, '/second', method='post').status_int, 200) self.assertRaises(HTTPMethodNotAllowed, lambda: web.ask(app, '/strict').status_int) self.assertEqual( web.ask(app, '/strict', method='post').status_int, 200)
def test_repr(self): # for coverage '%r' % web.WebHandler() '%r' % web.cases() '%r' % web.request_filter(lambda e, d, n: None) '%r' % web.match('/', 'index') '%r' % web.method('GET') '%r' % web.static_files('/prefix') '%r' % web.prefix('/prefix') '%r' % web.subdomain('name') '%r' % web.namespace('name')
def test_repr(self): # for coverage "%r" % web.WebHandler() "%r" % web.cases() "%r" % web.request_filter(lambda e, d, n: None) "%r" % web.match("/", "index") "%r" % web.method("GET") "%r" % web.static_files("/prefix") "%r" % web.prefix("/prefix") "%r" % web.subdomain("name") "%r" % web.namespace("name")
def logout(self, redirect_to='/'): ''' This property will return component which will handle logout requests. It only handles POST requests and do not display any rendered content. This handler deletes session id from `storage`. If there is no session id provided or id is incorrect handler silently redirects to login url and does not throw any exception. ''' def _logout(env, data): response = HTTPSeeOther(location=str(redirect_to)) self.logout_user(env.request, response) return response return web.match('/logout', 'logout') | web.method('post') | _logout
def logout(self, redirect_to='/'): ''' This property will return component which will handle logout requests. It only handles POST requests and do not display any rendered content. This handler deletes session id from `storage`. If there is no session id provided or id is incorrect handler silently redirects to login url and does not throw any exception. ''' def _logout(env, data): location = redirect_to if location is None and env.request.referer: location = env.request.referer elif location is None: location = '/' response = HTTPSeeOther(location=str(location)) self.logout_user(env.request, response) return response return web.match('/logout', 'logout') | web.method('post') | _logout
def app(self): return web.method('POST') | web.match('/edit', 'list_edit') | self
def app(self): return self.app_prefix | self.PrepareItemHandler(self) | web.cases( web.match('', '') | self, web.match('/autosave', 'autosave') | \ web.method('POST', strict=True) | self.autosave )
def app(self): return web.match('/%s' % self.action, self.action) | \ web.method('POST', strict=True) | \ self.PrepareItemHandler(self) | self
def app(self): return web.match('/<idconv:item>/%s' % self.action, self.action, convs={'idconv': self.stream.id_converter}) | \ web.method('POST', strict=True) | \ self.PrepareItemHandler(self) | self
def test_head(self): handler = web.method("GET") self.assertEqual(handler._names, set(["GET", "HEAD"]))
def test_head(self): handler = web.method('GET') self.assertEqual(handler._names, set(['GET', 'HEAD']))
web.cases( Rule('/', h.index, method='GET'), method('POST') | web.cases( Rule('/_update_lock/<string:item_id>/<string:edit_session>', h.update_lock), Rule('/_force_lock/<string:item_id>', h.force_lock), Rule('/_release_lock/<string:item_id>/<string:edit_session>', h.release_lock), web.match('/_tmp_img', 'load_tmp_image') | h.load_tmp_image, Rule('/_post_note', h.post_note), ), web.prefix('/tray') | web.cases( Rule('/<int:tray>', h.tray_view.tray), web.prefix('/_') | web.method('POST', strict=True) | web.cases( Rule('/put', h.tray_view.put_to_tray), Rule('/user/put', h.tray_view.put_to_user_tray), Rule('/delete', h.tray_view.delete_from_tray), ) ), streams.streams.to_app(), loners.loners.to_app(), web.prefix('/_front/<any(admin,front):version>/<any(en,ru):lang>', name='front') | front_environment | front_app, ), HTTPNotFound, # XXX does not work without this )