Skip to content

Class ScratchUserSession | Subcommands

Dylan Beswick edited this page Apr 8, 2016 · 8 revisions

Subcommands of ScratchUserSession

ScratchUserSession.backpack

Provides a read/write JSON interface with the user's "backpack", a feature of the scratch website.

ScratchUserSession.backpack.get - Get the JSON content the user's backpack.

Arguments:

  • payload [required] - a JSON object to be uploaded.

Fails: When the server returns a malformed JSON object.

ScratchUserSession.backpack.set - Write to the user's backpack

Arguments: None
Fails: When the server returns a malformed JSON object.


ScratchUserSession.cloud

Provides an interface for scratch's "cloud variables" via HTTP polling (see CloudSession for TCP socket interface).

ScratchUserSession.cloud.set_var - Set the value of a cloud variable.

Arguments:

  • var [required] - The name of the variable to be set.
  • value [required] - The value which the var should be set to.
  • projId [required] - The project ID of the project with the var.

Fails: When the session can't acquire a token needed for server validation.

ScratchUserSession.cloud.create_var - Creates a cloud variable.

Arguments:

  • var [required] - The name of the variable to be created.
  • value [required] - The value which the var should be set to.
  • projId [required] - The project ID of the project with the var.

Fails: When the session can't acquire a token needed for server validation.

ScratchUserSession.cloud.get_var - Gets the value of a cloud variable.

Arguments:

  • var [required] - The name of the variable.
  • projId [required] - The project ID of the project with the var.

Fails: When the variable name can't be found

ScratchUserSession.cloud.get_vars - Gets all the cloud variables and their values from a project.

Arguments:

  • projId [required] - The project ID of the project to read the variables from.

Fails: When the server returns a malformed JSON object.


ScratchUserSession.messages

Allows reading of messages and message counts.

ScratchUserSession.messages.get_message_count - Gets the message count of a user.

Arguments:

  • user [optional, defaults to current user] - The user.

Fails: When the server returns a malformed JSON object.

ScratchUserSession.messages.get_message_html - Gets the HTML of the user's messages page.

Arguments: None
Fails: Should not fail.


Clone this wiki locally