Opened 13 years ago

Closed 13 years ago

#17125 closed New feature (fixed)

The regex of an existing RegexField cannot be changed

Reported by: Claude Paroz Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords: regexfield
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, once you have instanciated a RegexField with a regex, it is not possible to change it afterwards (without big hacks).

Attachments (1)

17125.1.diff (2.0 KB ) - added by Claude Paroz 13 years ago.
Allow modification of regex after RegexField init

Download all attachments as: .zip

Change History (8)

by Claude Paroz, 13 years ago

Attachment: 17125.1.diff added

Allow modification of regex after RegexField init

comment:1 by Claude Paroz, 13 years ago

Has patch: set

comment:2 by Claude Paroz, 13 years ago

Patch needs improvement: set

I might have been a little too naive in my implementation. There seems to be a bunch of deepcopy issues when adding properties to form fields. More experts opinions welcome...

comment:3 by Claude Paroz, 13 years ago

After some investigation, it appears that the field validators list is shared between form base_fields and instance fields. When I modify validators in _set_regex, the base_fields 'url' validators list is also modified, hence future calls to create new forms will have a modified validators list, which is not intended.
If I subclass __deepcopy__ and add result.validators = self.validators[:], the problem I had disappears.
Is it a bug, a feature? Did I miss something?

comment:4 by Claude Paroz, 13 years ago

Problem with validators shared between form instances entered in #17127.

comment:5 by Claude Paroz, 13 years ago

Patch needs improvement: unset

The issue I had has been resolved in #17127. So the patch is still valid.

comment:6 by Julien Phalip, 13 years ago

Triage Stage: UnreviewedReady for checkin

comment:7 by Julien Phalip, 13 years ago

Resolution: fixed
Status: newclosed

In [17076]:

Fixed #17125 -- Made it possible to change a RegexField's regular expression validator after it has been initialized. Thanks to Claude Paroz for the report and patch.

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