Esempio n. 1
0
 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))
Esempio n. 2
0
 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
         )
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)
Esempio n. 5
0
 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
         )
Esempio n. 6
0
 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,
     )
Esempio n. 7
0
 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))
Esempio n. 8
0
 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),
         )
     )
Esempio n. 9
0
 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
         )
Esempio n. 10
0
 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
         )
Esempio n. 11
0
    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)
Esempio n. 12
0
 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')
Esempio n. 13
0
 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')
Esempio n. 14
0
 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")
Esempio n. 15
0
File: auth.py Progetto: riffm/iktomi
 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
Esempio n. 16
0
    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
Esempio n. 18
0
 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
         )
Esempio n. 19
0
 def app(self):
     return web.match('/%s' % self.action, self.action) | \
            web.method('POST', strict=True) | \
            self.PrepareItemHandler(self) | self
Esempio n. 20
0
 def app(self):
     return web.match('/%s' % self.action, self.action) | \
            web.method('POST', strict=True) | \
            self.PrepareItemHandler(self) | self
Esempio n. 21
0
 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
Esempio n. 22
0
 def test_head(self):
     handler = web.method("GET")
     self.assertEqual(handler._names, set(["GET", "HEAD"]))
Esempio n. 23
0
 def app(self):
     return web.method('POST') | web.match('/edit', 'list_edit') | self
Esempio n. 24
0
 def test_head(self):
     handler = web.method('GET')
     self.assertEqual(handler._names, set(['GET', 'HEAD']))
Esempio n. 25
0
 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
Esempio n. 26
0
 def test_head(self):
     handler = web.method('GET')
     self.assertEqual(handler._names, set(['GET', 'HEAD']))
Esempio n. 27
0
    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
)