|No such thing as a small change|
Scratchpads Revisited and some XML Node View Changesby demerphq (Chancellor)
|on Jun 13, 2004 at 22:41 UTC||Need Help??|
A whole slew of new scratchpad features have been rolled out today, in addition to a hopefully useful XML feature. If I've done my job right you shouldn't have noticed much. But there is always the possibility of bugs lurking so please feel free to let me or pmdev know of any issues you find.
The old scratchpads are now totally gone. This is good because it satisfies the initial intention, of lowering the cost of fetching user information on the site. Its also good because now its alot easier to handle the pads in a more flexible way. Its also good becuase it resolves some nits in the overall approach of supplying scratchpads only when a user wants them (an important objective as many of users are non participatory).
So what has really changed? Well scratchpads now have two parts. A private part for yourself only and a public part for others to see. The rendering logic for users viewing their own pads is a little lacking so expect improvements and please offer suggestions. Whats really changed is under the hood. The user table got a new column, called user_scratchpad which is now used to store the id of a users scratchpad if they have one. So XML heads will probably want to take advantage of this.
The other main change involved in this is that now Scratch Pad Viewer is a true proxy for handling nodes. This means that if a user who has no scratchpad wants to create it (a link is provided on their homenodes) go the Scratch Pad Viwer where the magic of creating a new pad is handled. This will work in XML as well, but more on that in a moment. Non owners wont see links to non existing scratchpads any more, and now the scratchpad viewer will tell you if the user has no pad instead of confusingly creating it on their behalf. If a user is allowed to edit a scratchpad then saying something like
will do the right thing regardless of whether they have a scratchpad or not. This should make writing clients that talk to PM easier.
The changes to the XML interface are twofold. One relates to scratchpads so we will handle that first. There is a new "passthrough mechanism" in place for XML nodes. If you request a node with "displaytype=xml" and "passthrough=1" and the node is configured appropriately by the gods then page specific non standard XML will result. In the case of the Scratch Pad Viewer youll see the XML for the selected users scratchpad in XML. This means you can do a single step fetch from username to scratchpad contents in XML. Its even more useful because it couples with the new proxy behaviour such that if you do both for a new user you get the new pads id in the returned XML.
The second set of useful changes was originally to help synchronization between PM and the pmdev test enviornment. This is the addition of two flags to the node xml display mode. Each are provided by passing "xmlstyle=FLAG" in the query. One is "clean" which returns the contents of fields without adding trailing newlines to start tags which is nice if your parser doesnt agree that these newlines should be ignored (like the parse used by the synchonization code). The second is "flat" which instead of returning useful fields in "data" element wrapped around multiple "field" elements (with other useful stuff at the root level), it will return one tag per field, with the tag named after the field. An attribute "field_name" will hold the true value of the DB field involved, and is normally the same as the name of the tag. (Flat implies and overrides clean.) Thus for de-merphq's scratchpad we have the "flat" and "normal" looks: (this is pasted from my browser the newlines are not as might be expected)
This makes it much easier to use certain parsers. Especially the version of XML::Simple in use on the site. For now these XML changes are restricted to the displaytype=xml mode, but its likely that ill port them to the other xml tickers if it makes sense to do so. Somewhen anyway :-)
Anway, I hope people enjoy and find this stuff useful.
First they ignore you, then they laugh at you, then they fight you, then you win.