Internal global data in Blender is stored in a structure made of datablocks.
It is a branching hierarchy. For example:
bpy.types.Object(ID) #which has sub categories such as..
active_shape_key
active_material
Or:
context.scene.render.filepath
(That is where the render output filepath is stored. It can be accessed, but not assigned, in a user's script.)
In a script it is possible to add one's own data block to this structure by linking it in this general way
bpy.types.XXXXXXXX.newDataAddress = bpy.props.TTTTTTT(parameters)
in which XXXXXX is an existing valid Blender datablock, TTTTTTT is the reserved word for the type of the data and 'parameters' are the permitted and required definitions. For example:
bpy.types.scene.new_data_name =
bpy.props.StringProperty(name = "TotalNotes" )
which can then be accessed through
bpy.data.scene["TotalNotes"]
Commonly, user data gets tagged onto the end of a passed argument called context, normally in the form:
self.context.userdata
--------------------------small print warnings ---------
The above is based on a what I have learnt since asking the question so it is not reliable.
/scripts/addonsespecially those by ideasman42 (campbell barton) and bart crouch. mont29. – zeffii Dec 08 '15 at 13:24