Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) 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.

Scratchpad Changes:

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

/index.pl?node_id=108949&user=demerphq&scratchpad_privatetext=Private& +scratchpad_doctext=Public

will do the right thing regardless of whether they have a scratchpad or not. This should make writing clients that talk to PM easier.

XML Changes:

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)

Flat:
<?xml version="1.0" encoding="ISO-8859-1" ?> <node id="366276" title="flux8's scratchpad" created="2004-06-13 13: +28:52" updated=""> <type id="182711">scratchpad</type> <author id="357600">flux8</author> <reputation field_name="reputation">0</reputation> <doctext field_name="doctext" /> <privatetext field_name="privatetext" /> </node>
Normal:
<?xml version="1.0" encoding="ISO-8859-1" ?> <node id="366276" title="flux8's scratchpad" created="2004-06-13 13:2 +8:52" updated=""> <type id="182711">scratchpad</type> <author id="357600">flux8</author> <data> <field name="reputation">0</field> <field name="doctext" /> <field name="privatetext" /> </data> </node>

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.


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi



In reply to Scratchpads Revisited and some XML Node View Changes by demerphq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-03-28 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found