BugsPatchesView violates DRY in repeating sort orderby values.
Bug #515584 reported by
Karl Fogel
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Fix Released
|
Low
|
Karl Fogel |
Bug Description
In lib/lp/
The Right Way would be, as intellectronica says, to "use zope's form machinery, which renders the form using the definition of an interface, validates the input (reloading the page with an error message) and finally collects the correct values in self.request.form". That is, "a zope form backed by an enum with all the options".
Related branches
lp:~kfogel/launchpad/515584-fix-DRY-violation
- Eleanor Berger (community): Approve (code ui)
-
Diff: 88 lines (+30/-34)2 files modifiedlib/lp/bugs/browser/bugtarget.py (+24/-6)
lib/lp/bugs/templates/bugtarget-patches.pt (+6/-28)
tags: | added: story-patch-report |
Changed in malone: | |
status: | Confirmed → In Progress |
milestone: | none → 10.02 |
Changed in malone: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
From a conversation with Tom Berger about how the Zope form fix would look:
The Zope form facility allows you to generate a form directly from an interface. So for example if you have a multiple choice field with an enum value, it will generate a combo with all the values.
1) Create an enum class (inherit from EnumeratedType), listing all the values you can sort by, in the browser .py file. For example, see 'class BranchListingSort' in lib/lp/ code/browser/ branchlisting. py.
2) Define an interface that describes the form. It will have one attribute, "orderby", whose value is the new enumerated type from (1). Do this in the browser .py file too (even though that might seem counterintuitive). For example, see 'class IBranchListingF ilter' in lib/lp/ code/browser/ branchlisting. py (though note that the relevant variable there is 'sort_by' instead of 'orderby').
3) Define the form class itself, which inherits from LaunchpadFormView and uses the interface as its schema. To do that, just assign a variable named 'schema' to the interface. For example, see 'class BranchListingView' in lib/lp/ code/browser/ branchlisting. py.