Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1664

Show
Ignore:
Timestamp:
06/16/07 15:36:00
Author:
fumanchu
Message:

Docstring update and more RFC terminology.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/http.py

    r1638 r1664  
    131131 
    132132class AcceptElement(HeaderElement): 
    133     """An element (with parameters) from an Accept-* header's element list.""" 
     133    """An element (with parameters) from an Accept* header's element list. 
     134     
     135    AcceptElement objects are comparable; the more-preferred object will be 
     136    "less than" the less-preferred object. They are also therefore sortable; 
     137    if you sort a list of AcceptElement objects, they will be listed in 
     138    priority order; the most preferred value will be first. Yes, it should 
     139    have been the other way around, but it's too late to fix now. 
     140    """ 
    134141     
    135142    def from_str(cls, elementstr): 
    136143        qvalue = None 
    137144        # The first "q" parameter (if any) separates the initial 
    138         # parameter(s) (if any) from the accept-params. 
     145        # media-range parameter(s) (if any) from the accept-params. 
    139146        atoms = q_separator.split(elementstr, 1) 
    140         initial_value = atoms.pop(0).strip() 
     147        media_range = atoms.pop(0).strip() 
    141148        if atoms: 
    142149            # The qvalue for an Accept header can have extensions. The other 
     
    144151            qvalue = HeaderElement.from_str(atoms[0].strip()) 
    145152         
    146         ival, params = cls.parse(initial_value) 
     153        media_type, params = cls.parse(media_range) 
    147154        if qvalue is not None: 
    148155            params["q"] = qvalue 
    149         return cls(ival, params) 
     156        return cls(media_type, params) 
    150157    from_str = classmethod(from_str) 
    151158     
     
    158165     
    159166    def __cmp__(self, other): 
    160         # If you sort a list of AcceptElement objects, they will be listed 
    161         # in priority order; the most preferred value will be first. 
    162167        diff = cmp(other.qvalue, self.qvalue) 
    163168        if diff == 0: 

Hosted by WebFaction

Log in as guest/cpguest to create tickets