Roan Kattouw wrote:
In general, I think most problems with action=edit are caused by the
fact that ApiEditPage currently just fools EditPage with a FauxRequest
object. There's a lot of mixture of UI and edit logic in EditPage, and I
think the best solution would be to split off the edit logic into a new
class.
Yes, that seems pretty obvious. We should not have two redundant
implementations of page editing, but simply two interfaces to the same
underlying code.
Looking at it from a MVC viewpoint, most of the API code in the past has
been pure View code, presenting data to the user but not modifying it.
Duplication there has not been an issue, especially as the view provided
by the API often differs significantly from that provided by the HTML
interface. Editing, however, involves Controller and Model code, and
you really do not want to have multiple redundant model implementations.
The right thing to do is to factor out the model (including
permissions checks etc.) into a separate module, for which both the API
and EditPage can serve as controllers and views.
--
Ilmari Karonen