API Docs for:
Show:

Charm Class

Module: models.charm
Parent Module: models

Charms, once instantiated and loaded with data from their respective sources, are immutable and read-only. This reflects the reality of how we interact with them.

Charm instances can represent both environment charms and charm store charms. A charm id is reliably and uniquely associated with a given charm only within a given context: the environment or the charm store.

Charms begin their lives with full charm ids, as provided by services in the environment and the charm store:

[SCHEME]:(~[OWNER]/)?[SERIES]/[PACKAGE NAME]-[REVISION]

With an id, we can instantiate a charm: typically we use db.charms.add({id: [ID]}). Finally, we load the charm's data over the network using the standard YUI Model method load, providing an object with a get_charm callable, and an optional callback (see YUI docs). Both the env and the charm store have a get_charm method, so, by design, it works easily: charm.load(env, optionalCallback) or charm.load(charm_store, optionalCallback). The get_charm method must either callback using the default YUI approach for this code, a boolean indicating failure, and a result; or it must return what the env version does: an object with a result object containing the charm data, or an object with an err attribute.

In both cases, environment charms and charm store charms, a charm's loaded attribute is set to true once it has all the data from its environment.

Methods

geetter

()

Generate the full name of the charm from its attributes.

getter

()

Generate the charm store path from the attributes of the charm.

last_change.writeOnce.setter

()

Normalize created value from float to date object.

revision.setter

()

Parse the revision number out of a string.

scheme.setter

()

If no value is given, "cs" is used as the default.

unsetIfNoValue

(
  • val
)

Helper to use a setter so that we can set null when the api returns an empty object.

Parameters:

  • val Object

    the Object to check if it's empty.