Opened 14 years ago
Closed 14 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)
Change History (8)
by , 14 years ago
| Attachment: | 17125.1.diff added |
|---|
comment:1 by , 14 years ago
| Has patch: | set |
|---|
comment:2 by , 14 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 , 14 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 , 14 years ago
Problem with validators shared between form instances entered in #17127.
comment:5 by , 14 years ago
| Patch needs improvement: | unset |
|---|
The issue I had has been resolved in #17127. So the patch is still valid.
comment:6 by , 14 years ago
| Triage Stage: | Unreviewed → Ready for checkin |
|---|
Allow modification of regex after RegexField init