Package Pyblosxom :: Module tools :: Class VariableDict
[hide private]
[frames] | no frames]

Class VariableDict

source code

Wraps around a standard dict allowing for escaped and urlencoding of internal data by tacking on a _urlencoded or a _escaped to the end of the key name.

Instance Methods [hide private]
string
__getitem__(self, key, default=None)
If the key ends with _escaped, then this will retrieve the value for the key and escape it.
source code
 
__init__(self)
Initializes the internal dict.
source code
 
__setitem__(self, key, value)
This calls __setitem__(key, value) on the wrapped dict.
source code
string
get(self, key, default=None)
This turns around and calls __getitem__(key, default).
source code
boolean
has_key(self, key)
If the key ends with _encoded or _urlencoded, we strip that off and then check the wrapped dict to see if it has the adjusted key.
source code
list of varies
keys(self)
Returns a list of the keys that can be accessed through __getitem__.
source code
 
update(self, newdict)
This calls update(newdict) on the wrapped dict.
source code
list of strings
values(self)
Returns a list of the values in this dict.
source code
Method Details [hide private]

__getitem__(self, key, default=None)
(Indexing operator)

source code 

If the key ends with _escaped, then this will retrieve the value for the key and escape it.

If the key ends with _urlencoded, then this will retrieve the value for the key and urlencode it.

Otherwise, this calls get(key, default) on the wrapped dict.
Parameters:
  • key (string) - the key to retrieve
  • default (string) - the default value to use if the key doesn't exist.
Returns: string
the value; escaped if the key ends in _escaped; urlencoded if the key ends in _urlencoded.

__setitem__(self, key, value)
(Index assignment operator)

source code 
This calls __setitem__(key, value) on the wrapped dict.
Parameters:
  • key (string) - the key
  • value (string) - the value

get(self, key, default=None)

source code 
This turns around and calls __getitem__(key, default).
Parameters:
  • key (string) - the key to retrieve
  • default (string) - the default value to use if the key doesn't exist.
Returns: string
__getitem__(key, default)

has_key(self, key)

source code 

If the key ends with _encoded or _urlencoded, we strip that off and then check the wrapped dict to see if it has the adjusted key.

Otherwise we call has_key(key) on the wrapped dict.
Parameters:
  • key (string) - the key to check for
Returns: boolean
1 if the key exists, 0 if not

keys(self)

source code 

Returns a list of the keys that can be accessed through __getitem__.

Note: this does not include the _encoded and _urlencoded versions of these keys.
Returns: list of varies
list of key names

values(self)

source code 
Returns a list of the values in this dict.
Returns: list of strings
list of values