Opened 16 years ago

Closed 10 years ago

#8690 closed New feature (fixed)

FormPreview should pass request to parse_params

Reported by: Bob Thomas Owned by: nobody
Component: contrib.formtools Version: dev
Severity: Normal Keywords: formpreview
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

It would be very useful to have request data in parse_params. The example given is to capture something like a user_id, but the main thing I would want to do here is to verify that the current user has permission to access the URL given. Of course, adding a parameter breaks backwards compatibility, so this is a similar request to #7222.

Attachments (2)

params.diff (973 bytes ) - added by Bob Thomas 16 years ago.
Add request parameter to parse_params
8690.diff (1.5 KB ) - added by Ramiro Morales 16 years ago.
Patch that tries to provide backwards compatibility. No tests and no docs yet, they can be added if idea isn't deeemed wrong

Download all attachments as: .zip

Change History (13)

by Bob Thomas, 16 years ago

Attachment: params.diff added

Add request parameter to parse_params

comment:1 by Bob Thomas, 16 years ago

Has patch: set
Keywords: formpreview added

comment:2 by Bob Thomas, 16 years ago

Forgot to mention, FormWizard's version of parse_params includes the request parameter.

comment:3 by Jacob, 16 years ago

Triage Stage: UnreviewedDesign decision needed

This unfortunately introduces a subtle backwards-incompatibility: if parse_params is defined in the old way (parse_params(*args, **kw)), then args[0] will become request with this patch, thereby breaking user code. So we need to make sure this is really a vital change before we make that change.

comment:4 by Bob Thomas, 16 years ago

I'm aware of the incompatibility (I mentioned it in the description), and it is unfortunate. We could define a new function like parse_request_params that passes request as the first argument (and calls parse_params without it), but I think that's a bit ugly.

This will only affect users that:

  1. Are overriding parse_params
  2. Are using unnamed args

Personally, I only use named arguments in URLconfs, but I can't speak for the rest of the community.

by Ramiro Morales, 16 years ago

Attachment: 8690.diff added

Patch that tries to provide backwards compatibility. No tests and no docs yet, they can be added if idea isn't deeemed wrong

comment:5 by Bob Thomas, 16 years ago

This works for me. Should we also add a DeprecationWarning for users who define parse_params the old way? Something like:

            import warnings
            warnings.warn(
                message = "Defining parse_params without the request parameter is deprecated. Define it as parse_params(self, request, *args, **kwargs) instead.",
                category = DeprecationWarning,
                stacklevel = 2
            )

comment:6 by Luke Plant, 14 years ago

Severity: Normal
Type: New feature

comment:7 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:8 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:9 by Jacob, 12 years ago

Triage Stage: Design decision neededAccepted

comment:10 by Tim Graham, 11 years ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set

comment:11 by Greg Chapple, 10 years ago

Resolution: fixed
Status: newclosed

formtools has been extracted into its own repository (​​​https://github.com/django/django-formtools/). Because of this, the issue tracking for this package has been moved to GitHub issues. I'm going to close this ticket, but I've created a GitHub issue to replace it where the conversation can continue: ​​​https://github.com/django/django-formtools/issues/22. Thanks!

Note: See TracTickets for help on using tickets.
Back to Top