Package lyntin :: Module manager :: Class Manager
[show private | hide private]
[frames | no frames]

Class Manager

Known Subclasses:
CommandManager, ConfigManager, HelpManager, HistoryManager

Base manager class for managing things in Lyntin. The Manager class gives all managers a standard way of interacting with sessions and user queries for information,
Method Summary
  __init__(self)
  addSession(self, newsession, basesession)
Tells the manager to create a new session based on another session.
  clear(self, ses)
Removes everything the manager was managing--essentially reinitializes it.
string getInfo(self, ses, text)
Returns information managed by this class.
list of mappings getInfoMappings(self, item, ses)
Returns a list of maps of parameter name -> value that represents all the info this manager is managing for this session.
list of strings getItems(self)
Returns a list of the items that this manager manages.
list of tuples getParameters(self, item)
Returns a list of tuples of the parameters we're storing in this manager and the description of each parameter.
string getStatus(self, ses)
Returns a one-liner status of the state of this manager for a given session.
  removeSession(self, ses)
Tells the manager to remove information regarding the session.

Method Details

addSession(self, newsession, basesession=None)

Tells the manager to create a new session based on another session. For example, when we connected to the 3k mud, we would tell all the managers to clone the common session to the new session created thus populating the new session.
Parameters:
newsession - the new session just created
           (type=Session)
basesession - the session to use as a template for the new session. most managers just copy the data from the basesession to the newsession. if this is None, then we don't want to clone from anything--we use None when Lyntin starts up and we create the common session.
           (type=Session)

clear(self, ses=None)

Removes everything the manager was managing--essentially reinitializes it. Override this to clear out the data your manager is managing. This is typically session oriented and gets called by the "#clear" command.
Parameters:
ses - the session this applies to--None if it applies to all sessions
           (type=session.Session)

getInfo(self, ses, text='')

Returns information managed by this class. This is mostly for display to the user--we shouldn't be using this method for Lyntin introspection.
Parameters:
text - allows the user to pass in a name filter which should show a subset of the data based on what names match the filter
           (type=string)
Returns:
a string of everything involved
           (type=string)

getInfoMappings(self, item, ses)

Returns a list of maps of parameter name -> value that represents all the info this manager is managing for this session.

For example, an AliasManager manages aliases and their expansions. Say it had three aliases a, b, and c which expand to "smile %1", "frown %1", and "kick %1". It would return:
  [
    { "alias": "a", "expansion": "smile %1" },
    { "alias": "b", "expansion": "frown %1" },
    { "alias": "c", "expansion": "kick %1" }
  ]
Parameters:
item - the item to get data for
           (type=string)
ses - the session in question
           (type=Session)
Returns:
a list of maps of parameter name -> value
           (type=list of mappings)

getItems(self)

Returns a list of the items that this manager manages. So the gag manager manages gags as well as antigags and would return:
  [ "gag", "antigag" ]

These items are used in getInfoMappings as well as getParameters.

If this manager doesn't manage anything, then it'll return an empty list.
Returns:
returns a list of strings
           (type=list of strings)

getParameters(self, item)

Returns a list of tuples of the parameters we're storing in this manager and the description of each parameter.

If this manager does not manage this item, it should raise a ValueError.
Parameters:
item - the item to get parameters for
           (type=string)
Returns:
list of (parameter, desc) tuples
           (type=list of tuples)

getStatus(self, ses)

Returns a one-liner status of the state of this manager for a given session. If this manager does not apply to sessions then it should return an empty string.

For example, the SubstituteManager which is holding 5 substitutes and 2 gags for a session named "3k" would return the string:
  "5 substitute(s). 2 gag(s)."
But the ThreadManager which is a globally scoped manager and doesn't apply to the "3k" session would return an empty string.
Parameters:
ses - the session to get status for
           (type=Session)
Returns:
a one-liner string of the status or an empty string
           (type=string)

removeSession(self, ses)

Tells the manager to remove information regarding the session.
Parameters:
ses - the session we no longer need to hold information for because the session has gone away
           (type=Session)

Generated by Epydoc 2.1 on Mon Aug 9 09:17:41 2004 http://epydoc.sf.net