django - Is this a good python design? -
django - Is this a good python design? -
i'm using django , wrote decorator take away of repetitive code found ajax views , want know sentiment (too basic, bad design, seek instead, ok, etc).
def ajax_only(func): def _ajax_only(request,*args,**kwargs): if not request.is_ajax(): homecoming httpresponse('<p>ajax not supported.</p>') else: homecoming func(request,*args,**kwargs) homecoming _ajax_only
yes, looks typical , effective utilize of decorator.
python django decorator
Comments
Post a Comment