Class ::xo::ConnectionContext

::xo::ConnectionContext[i] create ... \
           [ -mobile mobile ] \
           [ -requester requester ] \
           [ -url url ] \
           [ -user user ] \
           [ -user_id user_id ]

Defined in

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xo::Context[i]

Methods (to be applied on the object)

  • require (scripted, private)

     xo::ConnectionContext[i] require [ -url url ] [ -package_id package_id ] \
        [ -parameter parameter ] [ -user_id user_id ] \
        [ -actual_query actual_query ] [ -keep_cc keep_cc ]

    Create or reconfigure the current connection context, ::xo::cc.

    Switches:
    -url (optional)
    Request URL. Supply a valid URL outside a connection thread.
    -package_id (optional, defaults to "0")
    Package ID, or 0 to infer it from the URL.
    -parameter (optional)
    Query parameter declarations.
    -user_id (optional, defaults to "-1")
    User ID, or -1 to derive it from the request.
    -actual_query (optional, defaults to " ")
    Query string, or a single space to read it from the connection.
    -keep_cc (optional, defaults to "false")
    Keep the existing context when one is already present.

    Testcases:
    test_xo_cc

Methods (to be applied on instances)

  • eval_as_user (scripted, public)

     <instance of xo::ConnectionContext[i]> eval_as_user \
        [ -user_id user_id ] cmd

    Run a command as the specified different user. Essentially, this method updates xo::cc and the ad_conn array array with the specified user, runs the command and resets the user to the previous value.

    Switches:
    -user_id (optional, integer)
    switch temporarily to this user
    Parameters:
    cmd (required)
    command to be exevuted

    Testcases:
    create_test_items
  • form_parameter (scripted, public)

     <instance of xo::ConnectionContext[i]> form_parameter spec \
        [ default ]

    Read a form parameter, loading the request form on demand.

    Parameters:
    spec (required)
    Parameter name, optionally followed by :constraint.
    default (optional)
    Value to return when the parameter is absent.
    Returns:
    The value, or a list for a parameter marked as multiple.

    Testcases:
    create_workflow_with_instance, xowiki_test_cases
  • get_all_form_parameter (scripted, public)

     <instance of xo::ConnectionContext[i]> get_all_form_parameter

    Load the request form if necessary and return all form parameter name and value pairs.

    Testcases:
    xowiki_test_cases, create_form_with_form_instance
  • get_parameter (scripted, public)

     <instance of xo::ConnectionContext[i]> get_parameter name \
        [ default ]

    Read a per-connection parameter override.

    Parameters:
    name (required)
    Parameter name.
    default (optional)
    Value to return when no override is set.

    Testcases:
    xowiki_test_cases, link_tests
  • mobile (setter, public)

     <instance of xo::ConnectionContext[i]> mobile

    Get or set the mobile-client flag for this request. The initial value is based on the request user agent.

    Testcases:
    create_workflow_with_instance
  • permission (scripted, public)

     <instance of xo::ConnectionContext[i]> permission \
        -object_id object_id  -privilege privilege  [ -party_id party_id ]

    Call ::permission::permission_p but avoid multiple calls in the same request through caching in the connection context

    Switches:
    -object_id (required, integer)
    -privilege (required)
    -party_id (optional, integer)

    Testcases:
    xowiki_test_cases
  • query_parameter (scripted, public)

     <instance of xo::ConnectionContext[i]> query_parameter __spec \
        [ default ]

    Get query parameter with default and optional value constraints. In case the value check for the query parameter fails, and no further precautions are performed (::aa_test_noabort is set), the method raises an exception with "ad_return_complaint" and aborts the script.

    Parameters:
    __spec (required)
    has the formname or name:value_constraint
    default (optional)
    default value
    Returns:
    actual value of the query parameter

    Testcases:
    api__context, test_xo_cc, path_resolve
  • returnredirect (scripted, public)

     <instance of xo::ConnectionContext[i]> returnredirect \
        [ -allow_complete_url ] url

    Schedule a redirect to be sent when the package replies.

    Switches:
    -allow_complete_url (optional)
    Allow a complete URL as the redirect target.
    Parameters:
    url (required)
    Redirect target.
    Returns:
    The empty string.

    Testcases:
    xowiki_test_cases
  • set_parameter (scripted, public)

     <instance of xo::ConnectionContext[i]> set_parameter name value

    Set a per-connection parameter override and invalidate its cached lookup.

    Parameters:
    name (required)
    Parameter name.
    value (required)
    Value to store.

    Testcases:
    create_workflow_with_instance
  • url (setter, public)

     <instance of xo::ConnectionContext[i]> url

    Get or set the request URL stored in the connection context.

    Testcases:
    create_workflow_with_instance, xowiki_test_cases
  • user_id (setter, public)

     <instance of xo::ConnectionContext[i]> user_id

    Get or set the user ID stored on the connection context.

    See Also:
    • {xo::ConnectionContext instproc set_user_id}

    Testcases:
    xotcl_core_tutorial_2, create_workflow_with_instance, package_normalize_path, xowiki_test_cases, link_tests, slot_interactions, path_resolve, create_form_with_form_instance