Package svnmailer :: Package browser :: Module _base :: Class ParsedQuery
[show private | hide private]
[frames | no frames]

Class ParsedQuery

object --+
         |
        ParsedQuery


Class for query string parsing and modification
Method Summary
  __init__(self, query, delim)
Initialization
bool __contains__(self, key)
Returns whether key occurs in the query as parameter name
list __getitem__(self, key)
Returns the value list for parameter named key
str or unicode __str__(self)
Returns the query as string again
  add(self, toadd)
Adds certain key value pairs to the query
  modify(self, remove, add, set)
Summarizes certain query modification methods
  remove(self, keys)
Removes certain parameters from the query if present
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name...
  __getattribute__(...)
x.__getattribute__('name') <==> x.name...
  __hash__(x)
x.__hash__() <==> hash(x)...
  __reduce__(...)
helper for pickle...
  __reduce_ex__(...)
helper for pickle...
  __repr__(x)
x.__repr__() <==> repr(x)...
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value...
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T...

Instance Variable Summary
str _delim: The delimiter to use for reconstructing the query string
list _keyorder: Original order of the keys (['key', ...])
dict _query_dict: Dictionary of key->valuelist pairs ({'key': ['val1', 'val2'], ...})

Class Variable Summary
_sre.SRE_Pattern _QUERYRE: Regex for splitting a query string on possible delimiters (& and ;)

Method Details

__init__(self, query='', delim='&')
(Constructor)

Initialization
Parameters:
query - The query string to store
           (type=str or unicode or ParsedQuery)
delim - The delimiter for reconstructing the query
           (type=str)
Overrides:
__builtin__.object.__init__

__contains__(self, key)
(In operator)

Returns whether key occurs in the query as parameter name
Parameters:
key - The key to lookup
           (type=str or unicode)
Returns:
Does key occur?
           (type=bool)

__getitem__(self, key)
(Indexing operator)

Returns the value list for parameter named key

Don't modify the returned list without adjusting _keyorder, too. At best don't modify it directly at all :)

Parameters:
key - The key to lookup
           (type=str or unicode)
Returns:
The value list (['val1', 'val2', ...])
           (type=list)
Raises:
KeyError - The key does not exist

__str__(self)
(Informal representation operator)

Returns the query as string again
Returns:
The query as string (type depends on the input)
           (type=str or unicode)
Overrides:
__builtin__.object.__str__

add(self, toadd)

Adds certain key value pairs to the query
Parameters:
toadd - A sequence of key-value-pairs ((('key', 'value), ...))
           (type=sequence)

modify(self, remove=None, add=None, set=None)

Summarizes certain query modification methods

set is a convenience parameter, it's actually a combination of remove and add. The order of processing is:

  1. append the set parameters to remove and add
  2. apply remove
  3. apply add
Parameters:
remove - parameters to remove (see ParsedQuery.remove method)
           (type=sequence)
add - parameters to add (see ParsedQuery.add method)
           (type=sequence)
set - parameters to override (see ParsedQuery.add for the format)
           (type=sequence)

remove(self, keys)

Removes certain parameters from the query if present

Non-present parameters are silently ignored

Parameters:
keys - The names of the parameters to remove
           (type=sequence)

Instance Variable Details

_delim

The delimiter to use for reconstructing the query string
Type:
str

_keyorder

Original order of the keys (['key', ...])
Type:
list

_query_dict

Dictionary of key->valuelist pairs ({'key': ['val1', 'val2'], ...})
Type:
dict

Class Variable Details

_QUERYRE

Regex for splitting a query string on possible delimiters (& and ;)
Type:
_sre.SRE_Pattern
Value:
[&;]                                                                   

Generated by Epydoc 2.0 on Sun Sep 25 20:49:18 2005 http://epydoc.sf.net