Code

Opened 6 years ago

Closed 6 years ago

#6393 closed (wontfix)

Example of wrapping a generic method could be better

Reported by: garth Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: auth, generic views
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The example of wrapping a generic method in a login decorator is shown below

from django.views.generic.date_based import object_detail

@login_required
def limited_object_detail(*args, **kwargs):
    return object_detail(*args, **kwargs)

It is probably much easer and cleaner to do

from django.views.generic.date_based import object_detail

limited_object_detail = login_required(object_detail)

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

I'd prefer to leave this at it is. Your change only works in this particular case, whereas the more general form in the documents gives people the push to remind that it's "just a function" and they can put whatever they like in there.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.