Back to index

moin  1.9.0~rc2
Public Member Functions | Private Attributes
MoinMoin.support.xappy.fieldactions.SortableMarshaller Class Reference

List of all members.

Public Member Functions

def __init__
def marshall_string
def marshall_float
def marshall_date
def get_marshall_function

Private Attributes

 _err

Detailed Description

Implementation of marshalling for sortable values.

Definition at line 118 of file fieldactions.py.


Constructor & Destructor Documentation

Definition at line 122 of file fieldactions.py.

00122 
00123     def __init__(self, indexing=True):
00124         if indexing:
00125             self._err = errors.IndexerError
00126         else:
00127             self._err = errors.SearchError


Member Function Documentation

Get a function used to marshall values of a given sorttype.

Definition at line 162 of file fieldactions.py.

00162 
00163     def get_marshall_function(self, fieldname, sorttype):
00164         """Get a function used to marshall values of a given sorttype.
00165 
00166         """
00167         try:
00168             return {
00169                 None: self.marshall_string,
00170                 'string': self.marshall_string,
00171                 'float': self.marshall_float,
00172                 'date': self.marshall_date,
00173             }[sorttype]
00174         except KeyError:
00175             raise self._err("Unknown sort type %r for field %r" %
00176                             (sorttype, fieldname))
00177 

Here is the call graph for this function:

Marshall a value for sorting as a date.

Definition at line 150 of file fieldactions.py.

00150 
00151     def marshall_date(self, fieldname, value):
00152         """Marshall a value for sorting as a date.
00153 
00154         """
00155         try:
00156             value = parsedate.date_from_string(value)
00157         except ValueError, e:
00158             raise self._err("Value supplied to field %r must be a "
00159                             "valid date: was %r: error is '%s'" %
00160                             (fieldname, value, str(e)))
00161         return marshall.date_to_string(value)

Here is the caller graph for this function:

Marshall a value for sorting as a floating point value.

Definition at line 137 of file fieldactions.py.

00137 
00138     def marshall_float(self, fieldname, value):
00139         """Marshall a value for sorting as a floating point value.
00140 
00141         """
00142         # convert the value to a float
00143         try:
00144             value = float(value)
00145         except ValueError:
00146             raise self._err("Value supplied to field %r must be a "
00147                             "valid floating point number: was %r" %
00148                             (fieldname, value))
00149         return marshall.float_to_string(value)

Here is the caller graph for this function:

Marshall a value for sorting in lexicograpical order.

This returns the input as the output, since strings already sort in
lexicographical order.

Definition at line 128 of file fieldactions.py.

00128 
00129     def marshall_string(self, fieldname, value):
00130         """Marshall a value for sorting in lexicograpical order.
00131 
00132         This returns the input as the output, since strings already sort in
00133         lexicographical order.
00134 
00135         """
00136         return value

Here is the caller graph for this function:


Member Data Documentation

Definition at line 124 of file fieldactions.py.


The documentation for this class was generated from the following file: