Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#1563 closed enhancement (wontfix)

[patch] generic views should accept `manipulator` parameter

Reported by: mir@… Owned by: jacob
Component: Generic views Version: magic-removal
Severity: normal Keywords: manipulator
Cc: mir@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I'd like to be able to pass a Manipulator object into the generic views. This allows a very nice code pattern:

  • the view function handles fetching the required data and doing sanity checks, creates a manipulator and calls the generic view
  • the generic view handles all the ugly http and form processing, eventually calling the manipulator
  • the manipulator does all the customized field stuff (additional/modified fields)

Sometimes this needs to pass special parameters to the initializer of the manipulator (e.g., a ChangeManipulator) must prepopulate default values dependent on the some other parameter of the view).

I think this makes a great general pattern. I'm willing to put something up in the wiki if you're interested.

Attachments (2)

generic-views-manipulator.diff (1.9 KB) - added by mir@… 8 years ago.
generic-views-manipulator.2.diff (1.8 KB) - added by mir@… 8 years ago.

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by mir@…

Changed 8 years ago by mir@…

comment:1 Changed 8 years ago by mir@…

Removed first two lines which have confused trac

comment:3 Changed 8 years ago by odonian@…

Just another Django user who'd love to see this (seemingly small) change implemented; it would enhance and increase the use of generic views by quite a bit. My use case has a model with a field called modifiedBy, which points to the logged-in user. Currently I have to write a separate view and manipulator to take care of filling in that data, when it's just a slightly modified manipulator that's needed.

comment:4 Changed 8 years ago by adrian

  • Resolution set to wontfix
  • Status changed from new to closed

Because manipulators are going away, I don't think we should do this.

comment:5 Changed 8 years ago by anonymous

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Hmm, are you talking also about _custom_ manipulators, or only automatic manipulators?

This usage is specific for custom manipulators, and I can't imagine you really want to remove custom manipulators.

comment:6 Changed 8 years ago by jacob

  • Resolution set to wontfix
  • Status changed from reopened to closed

Reclosing -- see Adrian's words.

comment:7 Changed 8 years ago by mir@…

  • Resolution wontfix deleted
  • Status changed from closed to reopened

I assume that you went over this too fast. I asked a direct question to understand what you are doing:

Hmm, are you talking also about _custom_ manipulators, or only automatic manipulators?

This has not been answered, so I don't understand why you closed the ticket.

I don't want to play ping-pong or be obnoxious. If you really didn't want to answer this question, please state so that I know this has not been by accident.

Michael

comment:8 Changed 8 years ago by jacob

  • Resolution set to wontfix
  • Status changed from reopened to closed

Since manipulators won't be used by generic views in the near future, this would mean the proposed manipulator argument would cause pretty different behavior. I'm marking this wontfix again.

comment:9 Changed 8 years ago by mir@…

Thanks, Jacob.

Please understand that this is really valuable information for me. Now I know that I should simply copy the generic views that I use all the time and just change it, instead of patching it in the django source tree. That's also why it is helpful to see your tickets rejected rather than having your change in limbo, not knowing what will happen, maybe for months.

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.