﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
828	Same function used for GET and POST	aaronsw	Adrian Holovaty	"Django encourages the use of the same function for both GET and POST (not to mention DELETE) methods. For example, 'module.method' resolves to:

{{{
def method(request): ...
}}}

In the web app framework I wrote, it resolves to:

{{{
class method:
    def GET(self, request): ...
    def POST(self, request): ...
    ...
}}}

This ensures that POST functions don't accidentally leak into GETs. If both POST and GET want to reuse code, then they can add a new method to the class. This also allows this style:

{{{

...
(r'^/method/(.*)', 'module.method')
...

class method:
    GET = web.autodelegate(""GET_"")
    POST = web.autodelegate(""POST_"")
    
    def GET_(self, request): ... # index
    def GET_pagename(self, request): ...
    def POST_pagename(self, request): ...
}}}

which makes adding new URLs easy. The code for autodelegate is simply:

{{{
def autodelegate(prefix=''):
    def internal(self, request, arg):
        func = prefix+arg
        if hasattr(self, func): return getattr(self, func)(request)
        else: raise NotFound
    return internal
}}}"	defect	closed	Database layer (models, ORM)		normal	worksforme			Unreviewed	0	0	0	0	0	0
