[Xotcl] please help me understand some code

Matthew Smith chedderslam at gmail.com
Fri May 16 17:04:51 CEST 2008


I response to a forum post, someone wrote the code below, which creates an
xowiki object.  I am trying to work with the code but am not sure what some
of it means.  Here is the code, with questions below.
-------------------------------------------------------------------------
# -*- tcl-*-
# Sample prototype page to show different output formats
# Gustaf Neumann, May 2008
::xowiki::Object new -title "Multiple Output Types" -text {

  my initialize -parameter {
    {-format "text"}
  }

  proc content {} {
    my get_parameters

    switch $format {
      xml {
        set content_type text/xml
        set content {
            <districts>
                <district>
                    <COE_DISTRICT_NAME>VICKSBURG</COE_DISTRICT_NAME>
                    <DISTRICT_ABBREVIATION>MVK</DISTRICT_ABBREVIATION>
                </district>
                <district>
                    <COE_DISTRICT_NAME>NEW ORLEANS</COE_DISTRICT_NAME>
                    <DISTRICT_ABBREVIATION>MVN</DISTRICT_ABBREVIATION>
                </district>
                <district>
                    <COE_DISTRICT_NAME>ST. PAUL</COE_DISTRICT_NAME>
                    <DISTRICT_ABBREVIATION>MVP</DISTRICT_ABBREVIATION>
                </district>
            </districts>
        }
      }
      csv {
        set content_type text/csv
        ns_set put [ns_conn outputheaders] Content-Disposition
"attachment;filename=sample.csv"
        set content {
          VICKSBURG,MVK
          NEW ORLEANS,MVN
          ST. PAUL,MVP
        }
      }
      json {
        set content_type text/plain
        set content "
            \{
                districts:\{
                    district:\[
                        \{
                            coe_district_name:'VICKSBURG',
                            district_abbreviation:'MVK'
                        \},
                        \{
                            coe_district_name:'NEW ORLEANS',
                            district_abbreviation:'MVN'
                        \},
                        \{
                            coe_district_name:'ST. PAUL',
                            district_abbreviation:'MVP'
                        \}
                    \]
                \}
            \}
        "
      }
      default {
        return [[my info parent] description]
      }
    }
    ::xo::cc set_parameter master 0
    ::xo::cc set_parameter content-type $content_type
    return $content
  }
} -description {
  I am just a sample service that can return its content in different
  formats. <br>Call me e.g. with format
  <a href='multiple-output-types?format=xml'>xml</a>,
  <a href='multiple-output-types?format=csv'>csv</a>, or
  <a href='multiple-output-types?format=json'>json</a>.
}
---------------------------------------------------------------------
in the lines:
    ::xo::cc set_parameter master 0
    ::xo::cc set_parameter content-type $content_type
what does the "::xo::cc" mean?

If the object is being created, how do I reference the object?  For
instance, I would like to set a variable to "content".   How would I do
this?

Thank you for any help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://alice.wu-wien.ac.at/pipermail/xotcl/attachments/20080516/ec6b2759/attachment.html 


More information about the Xotcl mailing list