All pastes #1559491 Raw Edit

sec

public text v1 · immutable
#1559491 ·published 2009-09-09 08:31 UTC
rendered paste body
import weburls = ['/admin/(.*)', 'admin']def autodelegate(prefix=''):    def internal(self, arg):        if '/' in arg:            first, rest = arg.split('/', 1)            args = rest.split('/')            func = prefix + first        else:            func = prefix + arg            args = []                    if hasattr(self, func):            return getattr(self, func)(*args)        else:            return web.notfound()    return internalclass admin:    GET = autodelegate('GET_')    def GET_(self):        return "ko"    def GET_list(self):        return "ok"    def GET_add(self, a):        return str(a)    def GET_set(self, a, b):        return '%s %s' % (a, b)app = web.application(urls, globals())print app.request('/admin/')print app.request('/admin/list')print app.request('/admin/add/1')print app.request('/admin/set/1/2')